Skip to content

Commit

Permalink
thermal: trip: Define for_each_trip() macro
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rafaeljw committed Oct 20, 2023
1 parent 7886976 commit 234ed6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions drivers/thermal/thermal_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
enum thermal_notify_event event);

/* Helpers */
#define for_each_trip(__tz, __trip) \
for (__trip = __tz->trips; __trip - __tz->trips < __tz->num_trips; __trip++)

void __thermal_zone_set_trips(struct thermal_zone_device *tz);
int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
struct thermal_trip *trip);
Expand Down
7 changes: 4 additions & 3 deletions drivers/thermal/thermal_trip.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *),
void *data)
{
int i, ret;
struct thermal_trip *trip;
int ret;

for (i = 0; i < tz->num_trips; i++) {
ret = cb(&tz->trips[i], data);
for_each_trip(tz, trip) {
ret = cb(trip, data);
if (ret)
return ret;
}
Expand Down

0 comments on commit 234ed6f

Please sign in to comment.