647b3b0eca11a4d4f6797fa28620fe0a3c5b8d08
[openwrt/staging/wigyori.git] /
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()
6
7 The devres variant of thermal_add_hwmon_sysfs() only takes the thermal
8 zone structure pointer as parameter.
9
10 Actually, it uses the tz->device to add it in the devres list.
11
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.
16
17 [skipped imx thermal which did not apply cleanly and irrelevant on
18 mediatek target]
19
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>
25 ---
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(-)
40
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
44 return ret;
45 }
46
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");
50
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
55 return ret;
56 }
57
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");
61 }
62
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
66 goto err_alloc;
67 }
68
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");
72 }
73
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;
78 }
79
80 - ret = devm_thermal_add_hwmon_sysfs(tzdev);
81 + ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
82 if (ret)
83 dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
84
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
88 return PTR_ERR(tzd);
89 }
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))
93 dev_warn(adc_tm->dev,
94 "Failed to add hwmon sysfs attributes\n");
95 }
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
99 return ret;
100 }
101
102 - if (devm_thermal_add_hwmon_sysfs(chip->tz_dev))
103 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev))
104 dev_warn(&pdev->dev,
105 "Failed to add hwmon sysfs attributes\n");
106
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);
112
113 - if (devm_thermal_add_hwmon_sysfs(tzd))
114 + if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd))
115 dev_warn(priv->dev,
116 "Failed to add hwmon sysfs attributes\n");
117 }
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
121 return ret;
122 }
123
124 - if (devm_thermal_add_hwmon_sysfs(tzd))
125 + if (devm_thermal_add_hwmon_sysfs(dev, tzd))
126 dev_warn(dev,
127 "Failed to add hwmon sysfs attributes\n");
128
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);
134
135 - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
136 + if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd))
137 dev_warn(tmdev->dev,
138 "Failed to add hwmon sysfs attributes\n");
139 }
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
143 return 0;
144 }
145
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");
149
150 return 0;
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);
155 }
156
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)
159 {
160 struct thermal_zone_device **ptr;
161 int ret;
162 @@ -272,7 +272,7 @@ int devm_thermal_add_hwmon_sysfs(struct
163 }
164
165 *ptr = tz;
166 - devres_add(&tz->device, ptr);
167 + devres_add(dev, ptr);
168
169 return ret;
170 }
171 --- a/drivers/thermal/thermal_hwmon.h
172 +++ b/drivers/thermal/thermal_hwmon.h
173 @@ -17,7 +17,7 @@
174
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);
180 #else
181 static inline int
182 @@ -27,7 +27,7 @@ thermal_add_hwmon_sysfs(struct thermal_z
183 }
184
185 static inline int
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)
188 {
189 return 0;
190 }
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);
196
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");
200
201 return 0;