1 From cc9c60e9cfeeac45d63361fa8c085c43c4bdfe3a Mon Sep 17 00:00:00 2001
2 From: Daniel Lezcano <daniel.lezcano@linaro.org>
3 Date: Wed, 1 Mar 2023 21:14:36 +0100
4 Subject: [PATCH 08/42] thermal/hwmon: Use the right device for
5 devm_thermal_add_hwmon_sysfs()
7 The devres variant of thermal_add_hwmon_sysfs() only takes the thermal
8 zone structure pointer as parameter.
10 Actually, it uses the tz->device to add it in the devres list.
12 It is preferable to use the device registering the thermal zone
13 instead of the thermal zone device itself. That prevents the driver
14 accessing the thermal zone structure internals and it is from my POV
15 more correct regarding how devm_ is used.
17 [skipped imx thermal which did not apply cleanly and irrelevant on
20 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
21 Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #amlogic_thermal
22 Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> #sun8i_thermal
23 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek auxadc
24 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
26 drivers/thermal/amlogic_thermal.c | 2 +-
27 drivers/thermal/imx_sc_thermal.c | 2 +-
28 drivers/thermal/k3_bandgap.c | 2 +-
29 drivers/thermal/mediatek/auxadc_thermal.c | 2 +-
30 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 2 +-
31 drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 2 +-
32 drivers/thermal/qcom/tsens.c | 2 +-
33 drivers/thermal/qoriq_thermal.c | 2 +-
34 drivers/thermal/sun8i_thermal.c | 2 +-
35 drivers/thermal/tegra/tegra30-tsensor.c | 2 +-
36 drivers/thermal/thermal_hwmon.c | 4 ++--
37 drivers/thermal/thermal_hwmon.h | 4 ++--
38 drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
39 13 files changed, 15 insertions(+), 15 deletions(-)
41 --- a/drivers/thermal/amlogic_thermal.c
42 +++ b/drivers/thermal/amlogic_thermal.c
43 @@ -286,7 +286,7 @@ static int amlogic_thermal_probe(struct
47 - if (devm_thermal_add_hwmon_sysfs(pdata->tzd))
48 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd))
49 dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n");
51 ret = amlogic_thermal_initialize(pdata);
52 --- a/drivers/thermal/imx_sc_thermal.c
53 +++ b/drivers/thermal/imx_sc_thermal.c
54 @@ -120,7 +120,7 @@ static int imx_sc_thermal_probe(struct p
58 - if (devm_thermal_add_hwmon_sysfs(sensor->tzd))
59 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd))
60 dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n");
63 --- a/drivers/thermal/k3_bandgap.c
64 +++ b/drivers/thermal/k3_bandgap.c
65 @@ -222,7 +222,7 @@ static int k3_bandgap_probe(struct platf
69 - if (devm_thermal_add_hwmon_sysfs(data[id].tzd))
70 + if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd))
71 dev_warn(dev, "Failed to add hwmon sysfs attributes\n");
74 --- a/drivers/thermal/mediatek/auxadc_thermal.c
75 +++ b/drivers/thermal/mediatek/auxadc_thermal.c
76 @@ -1210,7 +1210,7 @@ static int mtk_thermal_probe(struct plat
77 goto err_disable_clk_peri_therm;
80 - ret = devm_thermal_add_hwmon_sysfs(tzdev);
81 + ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
83 dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
85 --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
86 +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
87 @@ -688,7 +688,7 @@ static int adc_tm5_register_tzd(struct a
90 adc_tm->channels[i].tzd = tzd;
91 - if (devm_thermal_add_hwmon_sysfs(tzd))
92 + if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd))
94 "Failed to add hwmon sysfs attributes\n");
96 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
97 +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
98 @@ -460,7 +460,7 @@ static int qpnp_tm_probe(struct platform
102 - if (devm_thermal_add_hwmon_sysfs(chip->tz_dev))
103 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev))
105 "Failed to add hwmon sysfs attributes\n");
107 --- a/drivers/thermal/qcom/tsens.c
108 +++ b/drivers/thermal/qcom/tsens.c
109 @@ -1056,7 +1056,7 @@ static int tsens_register(struct tsens_p
110 if (priv->ops->enable)
111 priv->ops->enable(priv, i);
113 - if (devm_thermal_add_hwmon_sysfs(tzd))
114 + if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd))
116 "Failed to add hwmon sysfs attributes\n");
118 --- a/drivers/thermal/qoriq_thermal.c
119 +++ b/drivers/thermal/qoriq_thermal.c
120 @@ -158,7 +158,7 @@ static int qoriq_tmu_register_tmu_zone(s
124 - if (devm_thermal_add_hwmon_sysfs(tzd))
125 + if (devm_thermal_add_hwmon_sysfs(dev, tzd))
127 "Failed to add hwmon sysfs attributes\n");
129 --- a/drivers/thermal/sun8i_thermal.c
130 +++ b/drivers/thermal/sun8i_thermal.c
131 @@ -468,7 +468,7 @@ static int sun8i_ths_register(struct ths
132 if (IS_ERR(tmdev->sensor[i].tzd))
133 return PTR_ERR(tmdev->sensor[i].tzd);
135 - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
136 + if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd))
138 "Failed to add hwmon sysfs attributes\n");
140 --- a/drivers/thermal/tegra/tegra30-tsensor.c
141 +++ b/drivers/thermal/tegra/tegra30-tsensor.c
142 @@ -530,7 +530,7 @@ static int tegra_tsensor_register_channe
146 - if (devm_thermal_add_hwmon_sysfs(tsc->tzd))
147 + if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd))
148 dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n");
151 --- a/drivers/thermal/thermal_hwmon.c
152 +++ b/drivers/thermal/thermal_hwmon.c
153 @@ -255,7 +255,7 @@ static void devm_thermal_hwmon_release(s
154 thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res);
157 -int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
158 +int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
160 struct thermal_zone_device **ptr;
162 @@ -272,7 +272,7 @@ int devm_thermal_add_hwmon_sysfs(struct
166 - devres_add(&tz->device, ptr);
167 + devres_add(dev, ptr);
171 --- a/drivers/thermal/thermal_hwmon.h
172 +++ b/drivers/thermal/thermal_hwmon.h
175 #ifdef CONFIG_THERMAL_HWMON
176 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
177 -int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
178 +int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz);
179 void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz);
182 @@ -27,7 +27,7 @@ thermal_add_hwmon_sysfs(struct thermal_z
186 -devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
187 +devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
191 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
192 +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
193 @@ -182,7 +182,7 @@ int ti_thermal_expose_sensor(struct ti_b
194 ti_bandgap_set_sensor_data(bgp, id, data);
195 ti_bandgap_write_update_interval(bgp, data->sensor_id, interval);
197 - if (devm_thermal_add_hwmon_sysfs(data->ti_thermal))
198 + if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal))
199 dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n");