aboutsummaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_trip.c
diff options
context:
space:
mode:
authorGravatar Rafael J. Wysocki <rafael.j.wysocki@intel.com> 2023-10-12 20:25:06 +0200
committerGravatar Rafael J. Wysocki <rafael.j.wysocki@intel.com> 2023-10-20 19:25:22 +0200
commit78869767f2ad3a98d2c830b718a503d8b0a94b26 (patch)
treecb6e8a3834125e710eefdadb9d0e34d1b4e04991 /drivers/thermal/thermal_trip.c
parentMerge branch 'acpi-thermal' (diff)
downloadlinux-78869767f2ad3a98d2c830b718a503d8b0a94b26.tar.gz
linux-78869767f2ad3a98d2c830b718a503d8b0a94b26.tar.bz2
linux-78869767f2ad3a98d2c830b718a503d8b0a94b26.zip
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 <rafael.j.wysocki@intel.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Tested-by: Lukasz Luba <lukasz.luba@arm.com>
Diffstat (limited to 'drivers/thermal/thermal_trip.c')
-rw-r--r--drivers/thermal/thermal_trip.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c
index 80f3cdb2f30e..6dff0dae6ef6 100644
--- a/drivers/thermal/thermal_trip.c
+++ b/drivers/thermal/thermal_trip.c
@@ -173,12 +173,9 @@ int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
int thermal_zone_trip_id(struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{
- int i;
-
- for (i = 0; i < tz->num_trips; i++) {
- if (&tz->trips[i] == trip)
- return i;
- }
-
- return -ENODATA;
+ /*
+ * Assume the trip to be located within the bounds of the thermal
+ * zone's trips[] table.
+ */
+ return trip - tz->trips;
}