]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal/drivers/sti: Depend on THERMAL_OF subsystem
authorRaphael Gallais-Pou <rgallaispou@gmail.com>
Tue, 16 Jul 2024 17:34:52 +0000 (19:34 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 2 Sep 2024 10:43:27 +0000 (12:43 +0200)
Switch to thermal_of_zone to handle thermal-zones. Replace
thermal_zone_device_register() by devm_thermal_of_zone_register() and
remove ops st_thermal_get_trip_type, st_thermal_get_trip_temp.

Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
Link: https://lore.kernel.org/r/20240716-thermal-v4-2-947b327e165c@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/Kconfig
drivers/thermal/st/st_thermal.c

index 55acbd141560c02f605459ccca7100a5cef4bddf..61e7ae524b1f8549591b35a43e0edcd132a89325 100644 (file)
@@ -438,7 +438,7 @@ source "drivers/thermal/samsung/Kconfig"
 endmenu
 
 menu "STMicroelectronics thermal drivers"
-depends on (ARCH_STI || ARCH_STM32) && OF
+depends on (ARCH_STI || ARCH_STM32) && THERMAL_OF
 source "drivers/thermal/st/Kconfig"
 endmenu
 
index 5f33543a3a54c7e468c6d08c2800fccc6b9bae15..a14a37d546982e95782ffc53f941a075bd1202e5 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/of_device.h>
 
 #include "st_thermal.h"
+#include "../thermal_hwmon.h"
 
 /* The Thermal Framework expects millidegrees */
 #define mcelsius(temp)                 ((temp) * 1000)
@@ -135,8 +136,6 @@ static struct thermal_zone_device_ops st_tz_ops = {
        .get_temp       = st_thermal_get_temp,
 };
 
-static struct thermal_trip trip;
-
 int st_thermal_register(struct platform_device *pdev,
                        const struct of_device_id *st_thermal_of_match)
 {
@@ -145,7 +144,6 @@ int st_thermal_register(struct platform_device *pdev,
        struct device_node *np = dev->of_node;
        const struct of_device_id *match;
 
-       int polling_delay;
        int ret;
 
        if (!np) {
@@ -197,29 +195,24 @@ int st_thermal_register(struct platform_device *pdev,
        if (ret)
                goto sensor_off;
 
-       polling_delay = sensor->ops->register_enable_irq ? 0 : 1000;
-
-       trip.temperature = sensor->cdata->crit_temp;
-       trip.type = THERMAL_TRIP_CRITICAL;
-
        sensor->thermal_dev =
-               thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, sensor,
-                                                       &st_tz_ops, NULL, 0, polling_delay);
+               devm_thermal_of_zone_register(dev, 0, sensor, &st_tz_ops);
        if (IS_ERR(sensor->thermal_dev)) {
-               dev_err(dev, "failed to register thermal zone device\n");
+               dev_err(dev, "failed to register thermal of zone\n");
                ret = PTR_ERR(sensor->thermal_dev);
                goto sensor_off;
        }
-       ret = thermal_zone_device_enable(sensor->thermal_dev);
-       if (ret)
-               goto tzd_unregister;
 
        platform_set_drvdata(pdev, sensor);
 
+       /*
+        * devm_thermal_of_zone_register() doesn't enable hwmon by default
+        * Enable it here
+        */
+       devm_thermal_add_hwmon_sysfs(dev, sensor->thermal_dev);
+
        return 0;
 
-tzd_unregister:
-       thermal_zone_device_unregister(sensor->thermal_dev);
 sensor_off:
        st_thermal_sensor_off(sensor);
 
@@ -232,7 +225,8 @@ void st_thermal_unregister(struct platform_device *pdev)
        struct st_thermal_sensor *sensor = platform_get_drvdata(pdev);
 
        st_thermal_sensor_off(sensor);
-       thermal_zone_device_unregister(sensor->thermal_dev);
+       thermal_remove_hwmon_sysfs(sensor->thermal_dev);
+       devm_thermal_of_zone_unregister(sensor->dev, sensor->thermal_dev);
 }
 EXPORT_SYMBOL_GPL(st_thermal_unregister);