]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
thermal/hwmon: Use the right device for devm_thermal_add_hwmon_sysfs()
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 1 Mar 2023 20:14:36 +0000 (21:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Jul 2023 17:39:25 +0000 (19:39 +0200)
[ Upstream commit 4a16c190f761cb3a87dcbbf355f91c71ce1f8c0b ]

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>
Stable-dep-of: 9301575df250 ("thermal/drivers/qoriq: Only enable supported sensors")
Signed-off-by: Sasha Levin <sashal@kernel.org>
14 files changed:
drivers/thermal/amlogic_thermal.c
drivers/thermal/imx8mm_thermal.c
drivers/thermal/imx_sc_thermal.c
drivers/thermal/k3_bandgap.c
drivers/thermal/mediatek/auxadc_thermal.c
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
drivers/thermal/qcom/tsens.c
drivers/thermal/qoriq_thermal.c
drivers/thermal/sun8i_thermal.c
drivers/thermal/tegra/tegra30-tsensor.c
drivers/thermal/thermal_hwmon.c
drivers/thermal/thermal_hwmon.h
drivers/thermal/ti-soc-thermal/ti-thermal-common.c

index 9235fda4ec1eba632d545b59c25f9de9dbd4de8a..337153042318f51de522fb9c428511a92f7a9fe7 100644 (file)
@@ -285,7 +285,7 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
                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);
index 72b5d6f319c1d0d9c603312c85bfea587145641f..e1bec196c5350d65ac4db594737db9f655835a84 100644 (file)
@@ -343,7 +343,7 @@ static int imx8mm_tmu_probe(struct platform_device *pdev)
                }
                tmu->sensors[i].hw_id = i;
 
-               if (devm_thermal_add_hwmon_sysfs(tmu->sensors[i].tzd))
+               if (devm_thermal_add_hwmon_sysfs(&pdev->dev, tmu->sensors[i].tzd))
                        dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n");
        }
 
index f32e59e7462316de443531bb76c6167687a2cfc1..e24572fc9e731a0ff1e81f0eafe15c0864f177da 100644 (file)
@@ -119,7 +119,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
                        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");
        }
 
index 22c9bcb899c37b21dde6ee48cb19b3cb93554fcb..df184b837cdd0d0eeefb656f8924feaf17686761 100644 (file)
@@ -222,7 +222,7 @@ static int k3_bandgap_probe(struct platform_device *pdev)
                        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");
        }
 
index ab730f9552d0e00a0a96c59c0f6441242e769994..585704d2df2beef0ed650cfdb7e755a9c09cf7d9 100644 (file)
@@ -1210,7 +1210,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
                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");
 
index 31164ade2dd11379045e7f14d26493184def35e1..dcb24a94f3fb4b787378f3d7431e60469e0a8a2e 100644 (file)
@@ -689,7 +689,7 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
                        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");
        }
index 101c75d0e13f3c6605dde08919f9ef7781909463..c0cfb255c14e255a47d2933d8c031c758615d992 100644 (file)
@@ -459,7 +459,7 @@ static int qpnp_tm_probe(struct platform_device *pdev)
                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");
 
index 2c02c86db6527243888bb643b0cdb2f82a7e3b95..38f5c783fb297dfd41dd668f378244614392f874 100644 (file)
@@ -1206,7 +1206,7 @@ static int tsens_register(struct tsens_priv *priv)
                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");
        }
index 431c29c0898a7be0f27bce265dad3a58b2d529ba..5c9205fe30733a08ae31bff6c555a8ceaff084d4 100644 (file)
@@ -157,7 +157,7 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev,
                        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");
 
index 31063e82afb69e53f2bc8b593485a17a4bf12936..7517067d6e817b084f35bb4474a303d857df0d55 100644 (file)
@@ -468,7 +468,7 @@ static int sun8i_ths_register(struct ths_device *tmdev)
                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");
        }
index b3218b71b6d976968be6bb023897fecac906d953..823560c82aaee51f83a5d48498bd110b23be1819 100644 (file)
@@ -528,7 +528,7 @@ static int tegra_tsensor_register_channel(struct tegra_tsensor *ts,
                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;
index c594c42bea6da21953997473400db879b23419b5..964db7941e31068875a8bae525fabea35d58291b 100644 (file)
@@ -263,7 +263,7 @@ static void devm_thermal_hwmon_release(struct device *dev, void *res)
        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;
@@ -280,7 +280,7 @@ int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
        }
 
        *ptr = tz;
-       devres_add(&tz->device, ptr);
+       devres_add(dev, ptr);
 
        return ret;
 }
index 1a9d65f6a6a8b1bdb15a6a9e19880cbc099417ed..b429f6e7abdb27bb70966014b0f5d1d35b32d252 100644 (file)
@@ -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_zone_device *tz)
 }
 
 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;
 }
index 8a9055bd376ec16a0487c4d4484ac9968f3d59d5..42d0ffd82514dc88e8732b74ca9d30afbfba1831 100644 (file)
@@ -182,7 +182,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
        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;