aboutsummaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_trip.c
diff options
context:
space:
mode:
authorGravatar Rafael J. Wysocki <rafael.j.wysocki@intel.com> 2023-09-21 19:52:44 +0200
committerGravatar Rafael J. Wysocki <rafael.j.wysocki@intel.com> 2023-09-28 12:55:29 +0200
commit2c7b4bfadef08cc0995c24a7b9eb120fe897165f (patch)
tree0383e2c46f7c79a502a4fc908d04885cc41c9a5e /drivers/thermal/thermal_trip.c
parentthermal: trip: Drop redundant trips check from for_each_thermal_trip() (diff)
downloadlinux-2c7b4bfadef08cc0995c24a7b9eb120fe897165f.tar.gz
linux-2c7b4bfadef08cc0995c24a7b9eb120fe897165f.tar.bz2
linux-2c7b4bfadef08cc0995c24a7b9eb120fe897165f.zip
thermal: core: Store trip pointer in struct thermal_instance
Replace the integer trip number stored in struct thermal_instance with a pointer to the relevant trip and adjust the code using the structure in question accordingly. The main reason for making this change is to allow the trip point to cooling device binding code more straightforward, as illustrated by subsequent modifications of the ACPI thermal driver, but it also helps to clarify the overall design and allows the governor code overhead to be reduced (through subsequent modifications). The only case in which it adds complexity is trip_point_show() that needs to walk the trips[] table to find the index of the given trip point, but this is not a critical path and the interface that trip_point_show() belongs to is problematic anyway (for instance, it doesn't cover the case when the same cooling devices is associated with multiple trip points). This is a preliminary change and the affected code will be refined by a series of subsequent modifications of thermal governors, the core and the ACPI thermal driver. The general functionality is not expected to be affected by this change. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/thermal/thermal_trip.c')
-rw-r--r--drivers/thermal/thermal_trip.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c
index 1cadb3b5d104..a8e92a89b2b8 100644
--- a/drivers/thermal/thermal_trip.c
+++ b/drivers/thermal/thermal_trip.c
@@ -157,3 +157,18 @@ int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
return 0;
}
+
+int thermal_zone_trip_id(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
+{
+ int i;
+
+ lockdep_assert_held(&tz->lock);
+
+ for (i = 0; i < tz->num_trips; i++) {
+ if (&tz->trips[i] == trip)
+ return i;
+ }
+
+ return -ENODATA;
+}