Skip to content

Commit a56cc0a

Browse files
committed
thermal: core: Add function to walk trips under zone lock
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 <[email protected]> Reviewed-by: Daniel Lezcano <[email protected]>
1 parent d069ed6 commit a56cc0a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/thermal/thermal_trip.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
2727
}
2828
EXPORT_SYMBOL_GPL(for_each_thermal_trip);
2929

30+
int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
31+
int (*cb)(struct thermal_trip *, void *),
32+
void *data)
33+
{
34+
int ret;
35+
36+
mutex_lock(&tz->lock);
37+
ret = for_each_thermal_trip(tz, cb, data);
38+
mutex_unlock(&tz->lock);
39+
40+
return ret;
41+
}
42+
EXPORT_SYMBOL_GPL(thermal_zone_for_each_trip);
43+
3044
int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
3145
{
3246
return tz->num_trips;

include/linux/thermal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
286286
int for_each_thermal_trip(struct thermal_zone_device *tz,
287287
int (*cb)(struct thermal_trip *, void *),
288288
void *data);
289+
int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
290+
int (*cb)(struct thermal_trip *, void *),
291+
void *data);
289292
int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
290293

291294
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);

0 commit comments

Comments
 (0)