From patchwork Tue Sep 25 09:03:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147410 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp472725lji; Tue, 25 Sep 2018 02:04:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV637r0gfn1JvS7+Ogss04KaIETQugITeHcarCXYMjBlQPvFrPOTYcMASROo/ukw7OSQoSH/E X-Received: by 2002:a62:7616:: with SMTP id r22-v6mr125529pfc.14.1537866264604; Tue, 25 Sep 2018 02:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866264; cv=none; d=google.com; s=arc-20160816; b=Vwt9ajmevBLTAaVuLz0m1ODQ/7tUeB43yJkLf1bvaFIq/7quIkXmek8n+0EBnGBUSU kk0gtpxlCv1nhtGMz3fuBLT1pvSyt15S8qhfnXkji8BSZcFBhtoGgDV8KgmtCnI1Y3rB weJ+hrwkKEmChcSKfxliHpiQUBOVFW8VGPsdxEpDIneQq49nCeAQTZ4OHx/ydoI6HOsq 0qPdRDknVmAU1QX9T65RXFI7GmmvhZWWk7OLs4TimXUQtVGhEmgWI8iRFSpVWDK3gIyR Iv0WMENuDp+y3isJDCEK6jOpL/rI1jYHRGvCJwYXxuap8AtBzAYwfEZkgt7wkpP439Qw WMYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=dQ1SJLj5088UNjU2Fxud7EyNCi+o0q8oCNTnh53fi/gU6xYGB2q7cBhoFzqdiwRg+5 Unskf5BF3oOZF8lW/O9SY2EUqcm1aWmguPsWjuvUT3M6ef8LP0yJNAoAmI+zmqVrdjGU j7JInQlc/fkFhezby0oIT+zB3H7Yw3e2HbYuBMPXX+JxTe+GZc9pu92I/dvyNgxaOr87 h6BxFWr3fk8LHGtfxIjAaDsa17u0JD77L3kn1yPMgFVzhJoPoe3M4cMLwCuD9B/BzFYk 7RJw6XAawYhVGb9AuNSnE1/ZlXMA/rxjyVi4IMkzprkyLoJpHVNH94X050smfmFrTpgt ePvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KM+fLMLg; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si1932374pgr.336.2018.09.25.02.04.24; Tue, 25 Sep 2018 02:04:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KM+fLMLg; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbeIYPKy (ORCPT + 10 others); Tue, 25 Sep 2018 11:10:54 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33445 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbeIYPKt (ORCPT ); Tue, 25 Sep 2018 11:10:49 -0400 Received: by mail-wr1-f67.google.com with SMTP id f10-v6so1444222wrs.0 for ; Tue, 25 Sep 2018 02:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=KM+fLMLgAtVQ6xfbHs0UQ7I/JbpTkxZz5SZVWDJdJ+JmlMxOk9U46qFHjE/DWvHi1p OokmN5ZIS8bWWyoEPYrmf42HIgs4P8DEqvVivJBZinAowF0rt4V92+qC2ynHUF62dcEb OzQoR0KNoHJWvpOCTkwgX8ZvGe6hYsgMDhcVk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=J2WcM1ipLec3KnbcKBwMeLOjAKJIrT86E4h+sEuRwc6NbVQZoF+d3/+bAdFew2Bdab 4c0sVbW0r7kFgCV2eT31p91E4c1GZJN0P9NhkS4/qoLpINcxYCNl+ZVLhQWatXArl4r/ CqIdVroBnUx7Tt9ouumS9TnxSeODW8gYO42Uvjl7c3RhOOHyyQaiL5ugYjHPlKKrfRv2 JW2geFuivEhdET33uPN/pP5uWIYzev9hOn8RisS9duurZKwzS8wJzBmDEKYVoTp20hae bl+pjcrW17SWluGeXkQ7ZrpnwotGSTDnJohZbEcAnVz+v0F6qeAstVnS/jNG6lscMAzd bWFQ== X-Gm-Message-State: ABuFfogvtD6MsO2O4qEwOnyHqoFP/XDVqSGfZsQ0i9xfyFE0xFeeD8CW FGTC+qBM11X+A8kOfjKKUzshzQ== X-Received: by 2002:a5d:5391:: with SMTP id d17-v6mr11507wrv.191.1537866254938; Tue, 25 Sep 2018 02:04:14 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:03 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Date: Tue, 25 Sep 2018 11:03:03 +0200 Message-Id: <1537866192-12320-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Convert the 'sensor' field to a pointer and propagate the change in the file. Havintg a pointer, gives us the opportunity to define multiple sensors. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 7287818..87b82fb 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -77,10 +77,11 @@ struct hisi_thermal_ops { struct hisi_thermal_data { const struct hisi_thermal_ops *ops; - struct hisi_thermal_sensor sensor; + struct hisi_thermal_sensor *sensor; struct platform_device *pdev; struct clk *clk; void __iomem *regs; + int nr_sensors; int irq; }; @@ -401,14 +402,29 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) return ret; } - data->sensor.id = HI6220_DEFAULT_SENSOR; + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + if (!data->sensor) + return -ENOMEM; + + data->sensor[0].id = HI6220_DEFAULT_SENSOR; + data->sensor[0].data = data; + data->nr_sensors = 1; return 0; } static int hi3660_thermal_probe(struct hisi_thermal_data *data) { - data->sensor.id = HI3660_DEFAULT_SENSOR; + struct platform_device *pdev = data->pdev; + struct device *dev = &pdev->dev; + + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + if (!data->sensor) + return -ENOMEM; + + data->sensor[0].id = HI3660_DEFAULT_SENSOR; + data->sensor[0].data = data; + data->nr_sensors = 1; return 0; } @@ -433,7 +449,7 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = &data->sensor[0]; int temp = 0; data->ops->irq_handler(sensor); @@ -444,7 +460,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", temp, sensor->thres_temp); - thermal_zone_device_update(data->sensor.tzd, + thermal_zone_device_update(data->sensor[0].tzd, THERMAL_EVENT_UNSPECIFIED); } else { @@ -535,7 +551,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->pdev = pdev; platform_set_drvdata(pdev, data); - data->sensor.data = data; data->ops = of_device_get_match_data(dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -553,13 +568,13 @@ static int hisi_thermal_probe(struct platform_device *pdev) if (ret) return ret; - ret = hisi_thermal_register_sensor(pdev, &data->sensor); + ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]); if (ret) { dev_err(dev, "failed to register thermal sensor: %d\n", ret); return ret; } - ret = data->ops->enable_sensor(&data->sensor); + ret = data->ops->enable_sensor(&data->sensor[0]); if (ret) { dev_err(dev, "Failed to setup the sensor: %d\n", ret); return ret; @@ -575,7 +590,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) } } - hisi_thermal_toggle_sensor(&data->sensor, true); + hisi_thermal_toggle_sensor(&data->sensor[0], true); return 0; } @@ -583,11 +598,11 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = &data->sensor[0]; hisi_thermal_toggle_sensor(sensor, false); - data->ops->disable_sensor(&data->sensor); + data->ops->disable_sensor(sensor); return 0; } @@ -597,7 +612,7 @@ static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - data->ops->disable_sensor(&data->sensor); + data->ops->disable_sensor(&data->sensor[0]); return 0; } @@ -606,7 +621,7 @@ static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - return data->ops->enable_sensor(&data->sensor); + return data->ops->enable_sensor(&data->sensor[0]); } #endif