Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/hwmon: Use the right device for devm_thermal_add_hwmon_sysfs()

The devres variant of thermal_add_hwmon_sysfs() only takes the thermal
zone structure pointer as parameter.

Actually, it uses the tz->device to add it in the devres list.

It is preferable to use the device registering the thermal zone
instead of the thermal zone device itself. That prevents the driver
accessing the thermal zone structure internals and it is from my POV
more correct regarding how devm_ is used.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #amlogic_thermal
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> #sun8i_thermal
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek auxadc
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Daniel Lezcano and committed by
Rafael J. Wysocki
4a16c190 8f3f4ad4

+16 -16
+1 -1
drivers/thermal/amlogic_thermal.c
··· 285 285 return ret; 286 286 } 287 287 288 - if (devm_thermal_add_hwmon_sysfs(pdata->tzd)) 288 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd)) 289 289 dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n"); 290 290 291 291 ret = amlogic_thermal_initialize(pdata);
+1 -1
drivers/thermal/imx8mm_thermal.c
··· 343 343 } 344 344 tmu->sensors[i].hw_id = i; 345 345 346 - if (devm_thermal_add_hwmon_sysfs(tmu->sensors[i].tzd)) 346 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, tmu->sensors[i].tzd)) 347 347 dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n"); 348 348 } 349 349
+1 -1
drivers/thermal/imx_sc_thermal.c
··· 116 116 return ret; 117 117 } 118 118 119 - if (devm_thermal_add_hwmon_sysfs(sensor->tzd)) 119 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd)) 120 120 dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n"); 121 121 } 122 122
+1 -1
drivers/thermal/k3_bandgap.c
··· 222 222 goto err_alloc; 223 223 } 224 224 225 - if (devm_thermal_add_hwmon_sysfs(data[id].tzd)) 225 + if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd)) 226 226 dev_warn(dev, "Failed to add hwmon sysfs attributes\n"); 227 227 } 228 228
+1 -1
drivers/thermal/mediatek/auxadc_thermal.c
··· 1210 1210 goto err_disable_clk_peri_therm; 1211 1211 } 1212 1212 1213 - ret = devm_thermal_add_hwmon_sysfs(tzdev); 1213 + ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev); 1214 1214 if (ret) 1215 1215 dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs"); 1216 1216
+1 -1
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
··· 689 689 return PTR_ERR(tzd); 690 690 } 691 691 adc_tm->channels[i].tzd = tzd; 692 - if (devm_thermal_add_hwmon_sysfs(tzd)) 692 + if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd)) 693 693 dev_warn(adc_tm->dev, 694 694 "Failed to add hwmon sysfs attributes\n"); 695 695 }
+1 -1
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
··· 459 459 return ret; 460 460 } 461 461 462 - if (devm_thermal_add_hwmon_sysfs(chip->tz_dev)) 462 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev)) 463 463 dev_warn(&pdev->dev, 464 464 "Failed to add hwmon sysfs attributes\n"); 465 465
+1 -1
drivers/thermal/qcom/tsens.c
··· 1189 1189 if (priv->ops->enable) 1190 1190 priv->ops->enable(priv, i); 1191 1191 1192 - if (devm_thermal_add_hwmon_sysfs(tzd)) 1192 + if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd)) 1193 1193 dev_warn(priv->dev, 1194 1194 "Failed to add hwmon sysfs attributes\n"); 1195 1195 }
+1 -1
drivers/thermal/qoriq_thermal.c
··· 157 157 return ret; 158 158 } 159 159 160 - if (devm_thermal_add_hwmon_sysfs(tzd)) 160 + if (devm_thermal_add_hwmon_sysfs(dev, tzd)) 161 161 dev_warn(dev, 162 162 "Failed to add hwmon sysfs attributes\n"); 163 163
+1 -1
drivers/thermal/sun8i_thermal.c
··· 475 475 if (IS_ERR(tmdev->sensor[i].tzd)) 476 476 return PTR_ERR(tmdev->sensor[i].tzd); 477 477 478 - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd)) 478 + if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd)) 479 479 dev_warn(tmdev->dev, 480 480 "Failed to add hwmon sysfs attributes\n"); 481 481 }
+1 -1
drivers/thermal/tegra/tegra30-tsensor.c
··· 528 528 return 0; 529 529 } 530 530 531 - if (devm_thermal_add_hwmon_sysfs(tsc->tzd)) 531 + if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd)) 532 532 dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n"); 533 533 534 534 return 0;
+2 -2
drivers/thermal/thermal_hwmon.c
··· 263 263 thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res); 264 264 } 265 265 266 - int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) 266 + int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz) 267 267 { 268 268 struct thermal_zone_device **ptr; 269 269 int ret; ··· 280 280 } 281 281 282 282 *ptr = tz; 283 - devres_add(&tz->device, ptr); 283 + devres_add(dev, ptr); 284 284 285 285 return ret; 286 286 }
+2 -2
drivers/thermal/thermal_hwmon.h
··· 17 17 18 18 #ifdef CONFIG_THERMAL_HWMON 19 19 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz); 20 - int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz); 20 + int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz); 21 21 void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz); 22 22 #else 23 23 static inline int ··· 27 27 } 28 28 29 29 static inline int 30 - devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) 30 + devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz) 31 31 { 32 32 return 0; 33 33 }
+1 -1
drivers/thermal/ti-soc-thermal/ti-thermal-common.c
··· 182 182 ti_bandgap_set_sensor_data(bgp, id, data); 183 183 ti_bandgap_write_update_interval(bgp, data->sensor_id, interval); 184 184 185 - if (devm_thermal_add_hwmon_sysfs(data->ti_thermal)) 185 + if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal)) 186 186 dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n"); 187 187 188 188 return 0;