Skip to content

Commit f2675e5

Browse files
committed
thermal: gov_fair_share: Fix dependency on trip points ordering
The computation in the fair share governor's get_trip_level() function currently works under the assumption that the temperature ordering of trips[] in a thermal zone is ascending, which need not be the case. However, get_trip_level() can be made work regardless of whether or not the trips table is ordered by temperature in any way, so change it accordingly. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent c6a783b commit f2675e5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/thermal/gov_fair_share.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@
1818
static int get_trip_level(struct thermal_zone_device *tz)
1919
{
2020
const struct thermal_trip *trip, *level_trip = NULL;
21-
int trip_level;
21+
int trip_level = -1;
2222

2323
for_each_trip(tz, trip) {
2424
if (trip->temperature >= tz->temperature)
25-
break;
25+
continue;
26+
27+
trip_level++;
2628

27-
level_trip = trip;
29+
if (!level_trip || trip->temperature > level_trip->temperature)
30+
level_trip = trip;
2831
}
2932

3033
/* Bail out if the temperature is not greater than any trips. */
31-
if (!level_trip)
34+
if (trip_level < 0)
3235
return 0;
3336

34-
trip_level = thermal_zone_trip_id(tz, level_trip);
35-
36-
trace_thermal_zone_trip(tz, trip_level, level_trip->type);
37+
trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, level_trip),
38+
level_trip->type);
3739

3840
return trip_level;
3941
}

0 commit comments

Comments
 (0)