aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-04 20:41:30 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-12-13 12:33:43 +0100
commit0c0c4740c9d2668a234f7743ba50d54acab0821c (patch)
tree7654eb05dd5c81f491bca164add68ee531f6e972 /drivers/thermal
parentb6515a88baf4628e93fcc39c2b81fc1740eb3c3f (diff)
downloadlinux-0c0c4740c9d2668a234f7743ba50d54acab0821c.tar.gz
thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
Make __thermal_zone_set_trips() use for_each_trip() instead of an open- coded loop over trip indices. 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_trip.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c
index 90861dec7eb0f..581f1cd883e58 100644
--- a/drivers/thermal/thermal_trip.c
+++ b/drivers/thermal/thermal_trip.c
@@ -63,25 +63,21 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips);
*/
void __thermal_zone_set_trips(struct thermal_zone_device *tz)
{
- struct thermal_trip trip;
+ const struct thermal_trip *trip;
int low = -INT_MAX, high = INT_MAX;
bool same_trip = false;
- int i, ret;
+ int ret;
lockdep_assert_held(&tz->lock);
if (!tz->ops->set_trips)
return;
- for (i = 0; i < tz->num_trips; i++) {
+ for_each_trip(tz, trip) {
bool low_set = false;
int trip_low;
- ret = __thermal_zone_get_trip(tz, i , &trip);
- if (ret)
- return;
-
- trip_low = trip.temperature - trip.hysteresis;
+ trip_low = trip->temperature - trip->hysteresis;
if (trip_low < tz->temperature && trip_low > low) {
low = trip_low;
@@ -89,9 +85,9 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz)
same_trip = false;
}
- if (trip.temperature > tz->temperature &&
- trip.temperature < high) {
- high = trip.temperature;
+ if (trip->temperature > tz->temperature &&
+ trip->temperature < high) {
+ high = trip->temperature;
same_trip = low_set;
}
}