linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linexp.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org
Cc: rui.zhang@intel.com, khilman@baylibre.com, abailon@baylibre.com,
	amitk@kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, Florian Fainelli <f.fainelli@gmail.com>,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>,
	Markus Mayer <mmayer@broadcom.com>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Zheng Yongjun <zhengyongjun3@huawei.com>,
	linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM
	BCM2711/BCM2835 ARM ARCHITECTURE),
	linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM
	BCM2711/BCM2835 ARM ARCHITECTURE)
Subject: [PATCH v1 10/33] thermal/drivers/broadcom: Switch to new of API
Date: Sun, 10 Jul 2022 23:24:00 +0200	[thread overview]
Message-ID: <20220710212423.681301-11-daniel.lezcano@linexp.org> (raw)
In-Reply-To: <20220710212423.681301-1-daniel.lezcano@linexp.org>

The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach.

Use this new API.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
---
 drivers/thermal/broadcom/bcm2711_thermal.c | 14 +++---
 drivers/thermal/broadcom/brcmstb_thermal.c | 20 ++++-----
 drivers/thermal/broadcom/ns-thermal.c      | 50 +++++++++-------------
 drivers/thermal/broadcom/sr-thermal.c      | 16 +++----
 4 files changed, 46 insertions(+), 54 deletions(-)

diff --git a/drivers/thermal/broadcom/bcm2711_thermal.c b/drivers/thermal/broadcom/bcm2711_thermal.c
index e9bef5c3414b..64d75593e760 100644
--- a/drivers/thermal/broadcom/bcm2711_thermal.c
+++ b/drivers/thermal/broadcom/bcm2711_thermal.c
@@ -31,11 +31,11 @@ struct bcm2711_thermal_priv {
 	struct thermal_zone_device *thermal;
 };
 
-static int bcm2711_get_temp(void *data, int *temp)
+static int bcm2711_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-	struct bcm2711_thermal_priv *priv = data;
-	int slope = thermal_zone_get_slope(priv->thermal);
-	int offset = thermal_zone_get_offset(priv->thermal);
+	struct bcm2711_thermal_priv *priv = tz->devdata;
+	int slope = thermal_zone_get_slope(tz);
+	int offset = thermal_zone_get_offset(tz);
 	u32 val;
 	int ret;
 
@@ -54,7 +54,7 @@ static int bcm2711_get_temp(void *data, int *temp)
 	return 0;
 }
 
-static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = {
+static struct thermal_zone_device_ops bcm2711_thermal_of_ops = {
 	.get_temp	= bcm2711_get_temp,
 };
 
@@ -88,8 +88,8 @@ static int bcm2711_thermal_probe(struct platform_device *pdev)
 	}
 	priv->regmap = regmap;
 
-	thermal = devm_thermal_zone_of_sensor_register(dev, 0, priv,
-						       &bcm2711_thermal_of_ops);
+	thermal = devm_thermal_of_zone_register(dev, 0, priv,
+						&bcm2711_thermal_of_ops);
 	if (IS_ERR(thermal)) {
 		ret = PTR_ERR(thermal);
 		dev_err(dev, "could not register sensor: %d\n", ret);
diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
index 0cedb8b4f00a..c459d14df3b5 100644
--- a/drivers/thermal/broadcom/brcmstb_thermal.c
+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
@@ -105,7 +105,7 @@ static struct avs_tmon_trip avs_tmon_trips[] = {
 struct brcmstb_thermal_params {
 	unsigned int offset;
 	unsigned int mult;
-	const struct thermal_zone_of_device_ops *of_ops;
+	struct thermal_zone_device_ops *of_ops;
 };
 
 struct brcmstb_thermal_priv {
@@ -150,9 +150,9 @@ static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv,
 		return (u32)((offset - temp) / mult);
 }
 
-static int brcmstb_get_temp(void *data, int *temp)
+static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-	struct brcmstb_thermal_priv *priv = data;
+	struct brcmstb_thermal_priv *priv = tz->devdata;
 	u32 val;
 	long t;
 
@@ -260,9 +260,9 @@ static irqreturn_t brcmstb_tmon_irq_thread(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int brcmstb_set_trips(void *data, int low, int high)
+static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int high)
 {
-	struct brcmstb_thermal_priv *priv = data;
+	struct brcmstb_thermal_priv *priv = tz->devdata;
 
 	dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);
 
@@ -288,7 +288,7 @@ static int brcmstb_set_trips(void *data, int low, int high)
 	return 0;
 }
 
-static const struct thermal_zone_of_device_ops brcmstb_16nm_of_ops = {
+static struct thermal_zone_device_ops brcmstb_16nm_of_ops = {
 	.get_temp	= brcmstb_get_temp,
 };
 
@@ -298,7 +298,7 @@ static const struct brcmstb_thermal_params brcmstb_16nm_params = {
 	.of_ops	= &brcmstb_16nm_of_ops,
 };
 
-static const struct thermal_zone_of_device_ops brcmstb_28nm_of_ops = {
+static struct thermal_zone_device_ops brcmstb_28nm_of_ops = {
 	.get_temp	= brcmstb_get_temp,
 	.set_trips	= brcmstb_set_trips,
 };
@@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table);
 
 static int brcmstb_thermal_probe(struct platform_device *pdev)
 {
-	const struct thermal_zone_of_device_ops *of_ops;
+	struct thermal_zone_device_ops *of_ops;
 	struct thermal_zone_device *thermal;
 	struct brcmstb_thermal_priv *priv;
 	struct resource *res;
@@ -341,8 +341,8 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, priv);
 	of_ops = priv->temp_params->of_ops;
 
-	thermal = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, priv,
-						       of_ops);
+	thermal = devm_thermal_of_zone_register(&pdev->dev, 0, priv,
+						of_ops);
 	if (IS_ERR(thermal)) {
 		ret = PTR_ERR(thermal);
 		dev_err(&pdev->dev, "could not register sensor: %d\n", ret);
diff --git a/drivers/thermal/broadcom/ns-thermal.c b/drivers/thermal/broadcom/ns-thermal.c
index c9468ba9d449..b9c3f2306bf5 100644
--- a/drivers/thermal/broadcom/ns-thermal.c
+++ b/drivers/thermal/broadcom/ns-thermal.c
@@ -14,19 +14,14 @@
 #define PVTMON_CONTROL0_SEL_TEST_MODE			0x0000000e
 #define PVTMON_STATUS					0x08
 
-struct ns_thermal {
-	struct thermal_zone_device *tz;
-	void __iomem *pvtmon;
-};
-
-static int ns_thermal_get_temp(void *data, int *temp)
+static int ns_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-	struct ns_thermal *ns_thermal = data;
-	int offset = thermal_zone_get_offset(ns_thermal->tz);
-	int slope = thermal_zone_get_slope(ns_thermal->tz);
+	void __iomem *pvtmon = tz->devdata;
+	int offset = thermal_zone_get_offset(tz);
+	int slope = thermal_zone_get_slope(tz);
 	u32 val;
 
-	val = readl(ns_thermal->pvtmon + PVTMON_CONTROL0);
+	val = readl(pvtmon + PVTMON_CONTROL0);
 	if ((val & PVTMON_CONTROL0_SEL_MASK) != PVTMON_CONTROL0_SEL_TEMP_MONITOR) {
 		/* Clear current mode selection */
 		val &= ~PVTMON_CONTROL0_SEL_MASK;
@@ -34,50 +29,47 @@ static int ns_thermal_get_temp(void *data, int *temp)
 		/* Set temp monitor mode (it's the default actually) */
 		val |= PVTMON_CONTROL0_SEL_TEMP_MONITOR;
 
-		writel(val, ns_thermal->pvtmon + PVTMON_CONTROL0);
+		writel(val, pvtmon + PVTMON_CONTROL0);
 	}
 
-	val = readl(ns_thermal->pvtmon + PVTMON_STATUS);
+	val = readl(pvtmon + PVTMON_STATUS);
 	*temp = slope * val + offset;
 
 	return 0;
 }
 
-static const struct thermal_zone_of_device_ops ns_thermal_ops = {
+static struct thermal_zone_device_ops ns_thermal_ops = {
 	.get_temp = ns_thermal_get_temp,
 };
 
 static int ns_thermal_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct ns_thermal *ns_thermal;
-
-	ns_thermal = devm_kzalloc(dev, sizeof(*ns_thermal), GFP_KERNEL);
-	if (!ns_thermal)
-		return -ENOMEM;
+	struct thermal_zone_device *tz;
+	void __iomem *pvtmon;
 
-	ns_thermal->pvtmon = of_iomap(dev_of_node(dev), 0);
-	if (WARN_ON(!ns_thermal->pvtmon))
+	pvtmon = of_iomap(dev_of_node(dev), 0);
+	if (WARN_ON(!pvtmon))
 		return -ENOENT;
 
-	ns_thermal->tz = devm_thermal_zone_of_sensor_register(dev, 0,
-							      ns_thermal,
-							      &ns_thermal_ops);
-	if (IS_ERR(ns_thermal->tz)) {
-		iounmap(ns_thermal->pvtmon);
-		return PTR_ERR(ns_thermal->tz);
+	tz = devm_thermal_of_zone_register(dev, 0,
+					   pvtmon,
+					   &ns_thermal_ops);
+	if (IS_ERR(tz)) {
+		iounmap(pvtmon);
+		return PTR_ERR(tz);
 	}
 
-	platform_set_drvdata(pdev, ns_thermal);
+	platform_set_drvdata(pdev, pvtmon);
 
 	return 0;
 }
 
 static int ns_thermal_remove(struct platform_device *pdev)
 {
-	struct ns_thermal *ns_thermal = platform_get_drvdata(pdev);
+	void __iomem *pvtmon = platform_get_drvdata(pdev);
 
-	iounmap(ns_thermal->pvtmon);
+	iounmap(pvtmon);
 
 	return 0;
 }
diff --git a/drivers/thermal/broadcom/sr-thermal.c b/drivers/thermal/broadcom/sr-thermal.c
index 85ab9edd580c..7c58eff407b3 100644
--- a/drivers/thermal/broadcom/sr-thermal.c
+++ b/drivers/thermal/broadcom/sr-thermal.c
@@ -19,7 +19,6 @@
 #define SR_TMON_MAX_LIST        6
 
 struct sr_tmon {
-	struct thermal_zone_device *tz;
 	unsigned int crit_temp;
 	unsigned int tmon_id;
 	struct sr_thermal *priv;
@@ -31,9 +30,9 @@ struct sr_thermal {
 	struct sr_tmon tmon[SR_TMON_MAX_LIST];
 };
 
-static int sr_get_temp(void *data, int *temp)
+static int sr_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-	struct sr_tmon *tmon = data;
+	struct sr_tmon *tmon = tz->devdata;
 	struct sr_thermal *sr_thermal = tmon->priv;
 
 	*temp = readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id));
@@ -41,13 +40,14 @@ static int sr_get_temp(void *data, int *temp)
 	return 0;
 }
 
-static const struct thermal_zone_of_device_ops sr_tz_ops = {
+static struct thermal_zone_device_ops sr_tz_ops = {
 	.get_temp = sr_get_temp,
 };
 
 static int sr_thermal_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct thermal_zone_device *tz;
 	struct sr_thermal *sr_thermal;
 	struct sr_tmon *tmon;
 	struct resource *res;
@@ -84,10 +84,10 @@ static int sr_thermal_probe(struct platform_device *pdev)
 		writel(0, sr_thermal->regs + SR_TMON_TEMP_BASE(i));
 		tmon->tmon_id = i;
 		tmon->priv = sr_thermal;
-		tmon->tz = devm_thermal_zone_of_sensor_register(dev, i, tmon,
-								&sr_tz_ops);
-		if (IS_ERR(tmon->tz))
-			return PTR_ERR(tmon->tz);
+		tz = devm_thermal_of_zone_register(dev, i, tmon,
+						   &sr_tz_ops);
+		if (IS_ERR(tz))
+			return PTR_ERR(tz);
 
 		dev_dbg(dev, "thermal sensor %d registered\n", i);
 	}
-- 
2.25.1


  parent reply	other threads:[~2022-07-10 21:25 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-10 21:23 [PATCH v1 00/33] New thermal OF code Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 01/33] thermal/of: Rework the thermal device tree initialization Daniel Lezcano
2022-07-12  2:40   ` Guenter Roeck
2022-07-10 21:23 ` [PATCH v1 02/33] thermal/of: Make new code and old code co-exist Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 03/33] thermal/drivers/rockchip: Switch to new of API Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 04/33] thermal/drivers/uniphier: " Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 05/33] thermal/drivers/generic-adc: " Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 06/33] thermal/drivers/mmio: " Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 07/33] thermal/drivers/tegra: " Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 08/33] thermal/drivers/sun8i: " Daniel Lezcano
2022-07-10 21:23 ` [PATCH v1 09/33] thermal/drivers/sprd: " Daniel Lezcano
2022-07-10 21:24 ` Daniel Lezcano [this message]
2022-07-11  2:37   ` [PATCH v1 10/33] thermal/drivers/broadcom: " Florian Fainelli
2022-07-10 21:24 ` [PATCH v1 11/33] thermal/drivers/qcom: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 12/33] thermal/drivers/st: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 13/33] thermal/drivers/amlogic: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 14/33] thermal/drivers/armada: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 15/33] thermal/drivers/db8500: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 16/33] thermal/drivers/imx: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 17/33] thermal/drivers/rcar: " Daniel Lezcano
2022-07-19  9:10   ` Niklas Söderlund
2022-07-22 19:34     ` Daniel Lezcano
2022-07-24 18:27     ` Daniel Lezcano
2022-07-24 19:00       ` Niklas Söderlund
2022-07-24 21:11         ` Daniel Lezcano
2022-07-24 22:39           ` Niklas Söderlund
2022-07-24 23:28             ` Niklas Söderlund
2022-07-25 10:00               ` Daniel Lezcano
2022-07-25 10:38                 ` Niklas Söderlund
2022-07-25 21:09                   ` Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 18/33] thermal/drivers/rzg2l: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 19/33] thermal/drivers/qoriq: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 20/33] thermal/drivers/mtk: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 21/33] thermal/drivers/banggap: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 22/33] thermal/drivers/maxim: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 23/33] thermal/drivers/hisilicon: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 24/33] thermal/drivers/ti-soc: " Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 25/33] ata/drivers/ahci_imx: Switch to new of thermal API Daniel Lezcano
2022-07-10 23:18   ` Damien Le Moal
2022-07-11  9:14     ` Daniel Lezcano
2022-07-11 10:37       ` Damien Le Moal
2022-07-10 21:24 ` [PATCH v1 26/33] hwmon/drivers: " Daniel Lezcano
2022-07-13 13:43   ` Guenter Roeck
2022-07-10 21:24 ` [PATCH v1 27/33] iio/drivers/sun4i_gpadc: " Daniel Lezcano
2022-07-11  7:52   ` Lars-Peter Clausen
2022-07-10 21:24 ` [PATCH v1 28/33] input/drivers/touchscreen_sun4i: " Daniel Lezcano
2022-07-11  3:28   ` Dmitry Torokhov
2022-07-10 21:24 ` [PATCH v1 29/33] regulator/drivers/max8976: " Daniel Lezcano
2022-07-11 11:02   ` Mark Brown
2022-07-10 21:24 ` [PATCH v1 30/33] thermal/drivers/bcm2835: " Daniel Lezcano
2022-07-11  2:40   ` Florian Fainelli
2022-07-10 21:24 ` [PATCH v1 31/33] thermal/drivers/samsung: " Daniel Lezcano
2022-07-11 10:41   ` Krzysztof Kozlowski
2022-07-10 21:24 ` [PATCH v1 32/33] thermal/core: Move set_trip_temp ops to the sysfs code Daniel Lezcano
2022-07-10 21:24 ` [PATCH v1 33/33] thermal/of: Remove old OF code Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220710212423.681301-11-daniel.lezcano@linexp.org \
    --to=daniel.lezcano@linexp.org \
    --cc=abailon@baylibre.com \
    --cc=amitk@kernel.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=f.fainelli@gmail.com \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mmayer@broadcom.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=stefan.wahren@i2se.com \
    --cc=zhengyongjun3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).