Skip to content

Commit 7886976

Browse files
committed
thermal: trip: Simplify computing trip indices
A trip index can be computed right away as a difference between the value of a trip pointer pointing to the given trip object and the start of the trips[] table in the given thermal zone, so change thermal_zone_trip_id() accordingly. No intentional functional impact (except for some speedup). Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Tested-by: Lukasz Luba <[email protected]>
1 parent a26b452 commit 7886976

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/thermal/thermal_trip.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,9 @@ int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
173173
int thermal_zone_trip_id(struct thermal_zone_device *tz,
174174
const struct thermal_trip *trip)
175175
{
176-
int i;
177-
178-
for (i = 0; i < tz->num_trips; i++) {
179-
if (&tz->trips[i] == trip)
180-
return i;
181-
}
182-
183-
return -ENODATA;
176+
/*
177+
* Assume the trip to be located within the bounds of the thermal
178+
* zone's trips[] table.
179+
*/
180+
return trip - tz->trips;
184181
}

0 commit comments

Comments
 (0)