Skip to content

Commit 234ed6f

Browse files
committed
thermal: trip: Define for_each_trip() macro
Define a new macro for_each_trip() to be used by the thermal core code and thermal governors for walking trips in a given thermal zone. Modify for_each_thermal_trip() to use this macro instead of an open- coded loop over trips. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]> Reviewed-by: Lukasz Luba <[email protected]>
1 parent 7886976 commit 234ed6f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

drivers/thermal/thermal_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
116116
enum thermal_notify_event event);
117117

118118
/* Helpers */
119+
#define for_each_trip(__tz, __trip) \
120+
for (__trip = __tz->trips; __trip - __tz->trips < __tz->num_trips; __trip++)
121+
119122
void __thermal_zone_set_trips(struct thermal_zone_device *tz);
120123
int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
121124
struct thermal_trip *trip);

drivers/thermal/thermal_trip.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
1313
int (*cb)(struct thermal_trip *, void *),
1414
void *data)
1515
{
16-
int i, ret;
16+
struct thermal_trip *trip;
17+
int ret;
1718

18-
for (i = 0; i < tz->num_trips; i++) {
19-
ret = cb(&tz->trips[i], data);
19+
for_each_trip(tz, trip) {
20+
ret = cb(trip, data);
2021
if (ret)
2122
return ret;
2223
}

0 commit comments

Comments
 (0)