thermal: core: Add function to walk trips under zone lock
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 3 Oct 2023 13:17:24 +0000 (15:17 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 5 Oct 2023 11:13:40 +0000 (13:13 +0200)
Add a wrapper around for_each_thermal_trip(), called
thermal_zone_for_each_trip(), that will invoke the former under the
thermal zone lock and pass its return value to the caller.

Two drivers will be modified subsequently to use this new function.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/thermal_trip.c
include/linux/thermal.h

index a8e92a8..8c649a8 100644 (file)
@@ -27,6 +27,20 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
 }
 EXPORT_SYMBOL_GPL(for_each_thermal_trip);
 
+int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
+                              int (*cb)(struct thermal_trip *, void *),
+                              void *data)
+{
+       int ret;
+
+       mutex_lock(&tz->lock);
+       ret = for_each_thermal_trip(tz, cb, data);
+       mutex_unlock(&tz->lock);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_for_each_trip);
+
 int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
 {
        return tz->num_trips;
index 6710a4a..2bab721 100644 (file)
@@ -286,6 +286,9 @@ int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
 int for_each_thermal_trip(struct thermal_zone_device *tz,
                          int (*cb)(struct thermal_trip *, void *),
                          void *data);
+int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
+                              int (*cb)(struct thermal_trip *, void *),
+                              void *data);
 int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
 
 int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);