aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-10-12 20:26:46 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-10-20 19:26:01 +0200
commit234ed6f5fbedf7bc84f9adc08c3e11ca8588ffd8 (patch)
tree3f9f0553ca9580c01d07b8b216e51f65f7cae7f1 /drivers/thermal
parent78869767f2ad3a98d2c830b718a503d8b0a94b26 (diff)
downloadlinux-234ed6f5fbedf7bc84f9adc08c3e11ca8588ffd8.tar.gz
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 <rafael.j.wysocki@intel.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_core.h3
-rw-r--r--drivers/thermal/thermal_trip.c7
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 024e82ebf5920..4702d3a152f90 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -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);
diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c
index 6dff0dae6ef69..9e07535d99bb4 100644
--- a/drivers/thermal/thermal_trip.c
+++ b/drivers/thermal/thermal_trip.c
@@ -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;
}