]> Git Repo - linux.git/commitdiff
thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
authorRafael J. Wysocki <[email protected]>
Mon, 4 Dec 2023 19:41:30 +0000 (20:41 +0100)
committerRafael J. Wysocki <[email protected]>
Wed, 13 Dec 2023 11:33:43 +0000 (12:33 +0100)
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 <[email protected]>
Acked-by: Daniel Lezcano <[email protected]>
Reviewed-by: Lukasz Luba <[email protected]>
drivers/thermal/thermal_trip.c

index 90861dec7eb0fdbdf0d186f19cdc4b1e45d890a7..581f1cd883e58e7149d139b3ac3013dd833c723b 100644 (file)
@@ -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;
                }
        }
This page took 0.05879 seconds and 4 git commands to generate.