[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2316634.ElGaqSPkdT@kreacher>
Date: Thu, 12 Oct 2023 20:26:46 +0200
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: Linux PM <linux-pm@...r.kernel.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Zhang Rui <rui.zhang@...el.com>,
Lukasz Luba <lukasz.luba@....com>
Subject: [PATCH v2 2/6] thermal: trip: Define for_each_trip() macro
From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
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@...el.com>
Acked-by: Daniel Lezcano <daniel.lezcano@...aro.org>
---
v1 -> v2:
* Rebase on top of current linux-next.
* Add the tag from Daniel.
---
drivers/thermal/thermal_core.h | 3 +++
drivers/thermal/thermal_trip.c | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
Index: linux-pm/drivers/thermal/thermal_core.h
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.h
+++ linux-pm/drivers/thermal/thermal_core.h
@@ -116,6 +116,9 @@ void __thermal_zone_device_update(struct
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);
Index: linux-pm/drivers/thermal/thermal_trip.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_trip.c
+++ linux-pm/drivers/thermal/thermal_trip.c
@@ -13,10 +13,11 @@ int for_each_thermal_trip(struct thermal
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;
}
Powered by blists - more mailing lists