iio/drivers/sun4i_gpadc: Switch to new of thermal API
authorDaniel Lezcano <daniel.lezcano@linexp.org>
Thu, 4 Aug 2022 22:43:44 +0000 (00:43 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 17 Aug 2022 12:09:39 +0000 (14:09 +0200)
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://lore.kernel.org/r/20220804224349.1926752-29-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/iio/adc/sun4i-gpadc-iio.c

index 2d393a4dfff6a8665ef980768993dc59b0cf2780..a6ade70dedf89fbfc9b97b14a6a4ce5edf78de33 100644 (file)
@@ -412,9 +412,9 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)
        return 0;
 }
 
-static int sun4i_gpadc_get_temp(void *data, int *temp)
+static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct sun4i_gpadc_iio *info = data;
+       struct sun4i_gpadc_iio *info = tz->devdata;
        int val, scale, offset;
 
        if (sun4i_gpadc_temp_read(info->indio_dev, &val))
@@ -428,7 +428,7 @@ static int sun4i_gpadc_get_temp(void *data, int *temp)
        return 0;
 }
 
-static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = {
+static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
        .get_temp = &sun4i_gpadc_get_temp,
 };
 
@@ -637,9 +637,9 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
        pm_runtime_enable(&pdev->dev);
 
        if (IS_ENABLED(CONFIG_THERMAL_OF)) {
-               info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
-                                                           0, info,
-                                                           &sun4i_ts_tz_ops);
+               info->tzd = devm_thermal_of_zone_register(info->sensor_device,
+                                                         0, info,
+                                                         &sun4i_ts_tz_ops);
                /*
                 * Do not fail driver probing when failing to register in
                 * thermal because no thermal DT node is found.
@@ -681,8 +681,6 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)
        if (!IS_ENABLED(CONFIG_THERMAL_OF))
                return 0;
 
-       thermal_zone_of_sensor_unregister(info->sensor_device, info->tzd);
-
        if (!info->no_irq)
                iio_map_array_unregister(indio_dev);