thermal/drivers/st: Use generic trip points
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 3 Oct 2022 09:25:53 +0000 (11:25 +0200)
committerDaniel Lezcano <daniel.lezcano@kernel.org>
Fri, 6 Jan 2023 13:14:47 +0000 (14:14 +0100)
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert to the generic trip points

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-21-daniel.lezcano@linaro.org
drivers/thermal/st/st_thermal.c

index 1276b95..1009f08 100644 (file)
@@ -134,48 +134,12 @@ static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature)
        return 0;
 }
 
-static int st_thermal_get_trip_type(struct thermal_zone_device *th,
-                               int trip, enum thermal_trip_type *type)
-{
-       struct st_thermal_sensor *sensor = th->devdata;
-       struct device *dev = sensor->dev;
-
-       switch (trip) {
-       case 0:
-               *type = THERMAL_TRIP_CRITICAL;
-               break;
-       default:
-               dev_err(dev, "invalid trip point\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static int st_thermal_get_trip_temp(struct thermal_zone_device *th,
-                                   int trip, int *temp)
-{
-       struct st_thermal_sensor *sensor = th->devdata;
-       struct device *dev = sensor->dev;
-
-       switch (trip) {
-       case 0:
-               *temp = mcelsius(sensor->cdata->crit_temp);
-               break;
-       default:
-               dev_err(dev, "Invalid trip point\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static struct thermal_zone_device_ops st_tz_ops = {
        .get_temp       = st_thermal_get_temp,
-       .get_trip_type  = st_thermal_get_trip_type,
-       .get_trip_temp  = st_thermal_get_trip_temp,
 };
 
+static struct thermal_trip trip;
+
 int st_thermal_register(struct platform_device *pdev,
                        const struct of_device_id *st_thermal_of_match)
 {
@@ -238,9 +202,12 @@ int st_thermal_register(struct platform_device *pdev,
 
        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(dev_name(dev), 1, 0, sensor,
-                                            &st_tz_ops, NULL, 0, polling_delay);
+               thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, 0, sensor,
+                                                       &st_tz_ops, NULL, 0, polling_delay);
        if (IS_ERR(sensor->thermal_dev)) {
                dev_err(dev, "failed to register thermal zone device\n");
                ret = PTR_ERR(sensor->thermal_dev);