Skip to content

Commit 276f1ed

Browse files
committed
thermal: gov_fair_share: Rearrange get_trip_level()
Make get_trip_level() use for_each_trip() to iterate over trip points and make it call thermal_zone_trip_id() to obtain the integer ID of a given trip point so as to avoid relying on the knowledge of struct thermal_zone_device internals. The general functionality is not expected to be changed. This change causes the governor to use trip pointers instead of trip indices everywhere except for the fair_share_throttle() second argument that will be modified subsequently along with the definition of the governor .throttle() callback. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent 234ed6f commit 276f1ed

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

drivers/thermal/gov_fair_share.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,27 @@
1515

1616
#include "thermal_core.h"
1717

18-
/**
19-
* get_trip_level: - obtains the current trip level for a zone
20-
* @tz: thermal zone device
21-
*/
2218
static int get_trip_level(struct thermal_zone_device *tz)
2319
{
24-
struct thermal_trip trip;
25-
int count;
20+
const struct thermal_trip *trip, *level_trip = NULL;
21+
int trip_level;
2622

27-
for (count = 0; count < tz->num_trips; count++) {
28-
__thermal_zone_get_trip(tz, count, &trip);
29-
if (tz->temperature < trip.temperature)
23+
for_each_trip(tz, trip) {
24+
if (trip->temperature >= tz->temperature)
3025
break;
26+
27+
level_trip = trip;
3128
}
3229

33-
/*
34-
* count > 0 only if temperature is greater than first trip
35-
* point, in which case, trip_point = count - 1
36-
*/
37-
if (count > 0)
38-
trace_thermal_zone_trip(tz, count - 1, trip.type);
30+
/* Bail out if the temperature is not greater than any trips. */
31+
if (!level_trip)
32+
return 0;
33+
34+
trip_level = thermal_zone_trip_id(tz, level_trip);
35+
36+
trace_thermal_zone_trip(tz, trip_level, level_trip->type);
3937

40-
return count;
38+
return trip_level;
4139
}
4240

4341
static long get_target_state(struct thermal_zone_device *tz,

0 commit comments

Comments
 (0)