123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- From cc9c60e9cfeeac45d63361fa8c085c43c4bdfe3a Mon Sep 17 00:00:00 2001
- From: Daniel Lezcano <[email protected]>
- Date: Wed, 1 Mar 2023 21:14:36 +0100
- Subject: [PATCH 08/42] 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.
- [skipped imx thermal which did not apply cleanly and irrelevant on
- mediatek target]
- Signed-off-by: Daniel Lezcano <[email protected]>
- Acked-by: Martin Blumenstingl <[email protected]> #amlogic_thermal
- Acked-by: Jernej Skrabec <[email protected]> #sun8i_thermal
- Reviewed-by: AngeloGioacchino Del Regno <[email protected]> #MediaTek auxadc
- Signed-off-by: Rafael J. Wysocki <[email protected]>
- ---
- drivers/thermal/amlogic_thermal.c | 2 +-
- drivers/thermal/imx_sc_thermal.c | 2 +-
- drivers/thermal/k3_bandgap.c | 2 +-
- drivers/thermal/mediatek/auxadc_thermal.c | 2 +-
- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 2 +-
- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 2 +-
- drivers/thermal/qcom/tsens.c | 2 +-
- drivers/thermal/qoriq_thermal.c | 2 +-
- drivers/thermal/sun8i_thermal.c | 2 +-
- drivers/thermal/tegra/tegra30-tsensor.c | 2 +-
- drivers/thermal/thermal_hwmon.c | 4 ++--
- drivers/thermal/thermal_hwmon.h | 4 ++--
- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
- 13 files changed, 15 insertions(+), 15 deletions(-)
- --- a/drivers/thermal/amlogic_thermal.c
- +++ b/drivers/thermal/amlogic_thermal.c
- @@ -286,7 +286,7 @@ static int amlogic_thermal_probe(struct
- return ret;
- }
-
- - if (devm_thermal_add_hwmon_sysfs(pdata->tzd))
- + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd))
- dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n");
-
- ret = amlogic_thermal_initialize(pdata);
- --- a/drivers/thermal/imx_sc_thermal.c
- +++ b/drivers/thermal/imx_sc_thermal.c
- @@ -120,7 +120,7 @@ static int imx_sc_thermal_probe(struct p
- return ret;
- }
-
- - if (devm_thermal_add_hwmon_sysfs(sensor->tzd))
- + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd))
- dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n");
- }
-
- --- a/drivers/thermal/k3_bandgap.c
- +++ b/drivers/thermal/k3_bandgap.c
- @@ -222,7 +222,7 @@ static int k3_bandgap_probe(struct platf
- goto err_alloc;
- }
-
- - if (devm_thermal_add_hwmon_sysfs(data[id].tzd))
- + if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd))
- dev_warn(dev, "Failed to add hwmon sysfs attributes\n");
- }
-
- --- a/drivers/thermal/mediatek/auxadc_thermal.c
- +++ b/drivers/thermal/mediatek/auxadc_thermal.c
- @@ -1210,7 +1210,7 @@ static int mtk_thermal_probe(struct plat
- goto err_disable_clk_peri_therm;
- }
-
- - ret = devm_thermal_add_hwmon_sysfs(tzdev);
- + ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
- if (ret)
- dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
-
- --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
- +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
- @@ -688,7 +688,7 @@ static int adc_tm5_register_tzd(struct a
- return PTR_ERR(tzd);
- }
- adc_tm->channels[i].tzd = tzd;
- - if (devm_thermal_add_hwmon_sysfs(tzd))
- + if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd))
- dev_warn(adc_tm->dev,
- "Failed to add hwmon sysfs attributes\n");
- }
- --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
- +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
- @@ -460,7 +460,7 @@ static int qpnp_tm_probe(struct platform
- return ret;
- }
-
- - if (devm_thermal_add_hwmon_sysfs(chip->tz_dev))
- + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev))
- dev_warn(&pdev->dev,
- "Failed to add hwmon sysfs attributes\n");
-
- --- a/drivers/thermal/qcom/tsens.c
- +++ b/drivers/thermal/qcom/tsens.c
- @@ -1056,7 +1056,7 @@ static int tsens_register(struct tsens_p
- if (priv->ops->enable)
- priv->ops->enable(priv, i);
-
- - if (devm_thermal_add_hwmon_sysfs(tzd))
- + if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd))
- dev_warn(priv->dev,
- "Failed to add hwmon sysfs attributes\n");
- }
- --- a/drivers/thermal/qoriq_thermal.c
- +++ b/drivers/thermal/qoriq_thermal.c
- @@ -158,7 +158,7 @@ static int qoriq_tmu_register_tmu_zone(s
- return ret;
- }
-
- - if (devm_thermal_add_hwmon_sysfs(tzd))
- + if (devm_thermal_add_hwmon_sysfs(dev, tzd))
- dev_warn(dev,
- "Failed to add hwmon sysfs attributes\n");
-
- --- a/drivers/thermal/sun8i_thermal.c
- +++ b/drivers/thermal/sun8i_thermal.c
- @@ -468,7 +468,7 @@ static int sun8i_ths_register(struct ths
- if (IS_ERR(tmdev->sensor[i].tzd))
- return PTR_ERR(tmdev->sensor[i].tzd);
-
- - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
- + if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd))
- dev_warn(tmdev->dev,
- "Failed to add hwmon sysfs attributes\n");
- }
- --- a/drivers/thermal/tegra/tegra30-tsensor.c
- +++ b/drivers/thermal/tegra/tegra30-tsensor.c
- @@ -530,7 +530,7 @@ static int tegra_tsensor_register_channe
- return 0;
- }
-
- - if (devm_thermal_add_hwmon_sysfs(tsc->tzd))
- + if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd))
- dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n");
-
- return 0;
- --- a/drivers/thermal/thermal_hwmon.c
- +++ b/drivers/thermal/thermal_hwmon.c
- @@ -255,7 +255,7 @@ static void devm_thermal_hwmon_release(s
- thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res);
- }
-
- -int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
- +int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
- {
- struct thermal_zone_device **ptr;
- int ret;
- @@ -272,7 +272,7 @@ int devm_thermal_add_hwmon_sysfs(struct
- }
-
- *ptr = tz;
- - devres_add(&tz->device, ptr);
- + devres_add(dev, ptr);
-
- return ret;
- }
- --- a/drivers/thermal/thermal_hwmon.h
- +++ b/drivers/thermal/thermal_hwmon.h
- @@ -17,7 +17,7 @@
-
- #ifdef CONFIG_THERMAL_HWMON
- int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
- -int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
- +int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz);
- void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz);
- #else
- static inline int
- @@ -27,7 +27,7 @@ thermal_add_hwmon_sysfs(struct thermal_z
- }
-
- static inline int
- -devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
- +devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
- {
- return 0;
- }
- --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
- +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
- @@ -182,7 +182,7 @@ int ti_thermal_expose_sensor(struct ti_b
- ti_bandgap_set_sensor_data(bgp, id, data);
- ti_bandgap_write_update_interval(bgp, data->sensor_id, interval);
-
- - if (devm_thermal_add_hwmon_sysfs(data->ti_thermal))
- + if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal))
- dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n");
-
- return 0;
|