summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_trip.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/thermal_trip.c')
-rw-r--r--drivers/thermal/thermal_trip.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c
index afc9499128..e42456442c 100644
--- a/drivers/thermal/thermal_trip.c
+++ b/drivers/thermal/thermal_trip.c
@@ -13,12 +13,11 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *),
void *data)
{
- int i, ret;
-
- lockdep_assert_held(&tz->lock);
+ struct thermal_trip *trip;
+ int ret;
- for (i = 0; i < tz->num_trips; i++) {
- ret = cb(&tz->trips[i], data);
+ for_each_trip(tz, trip) {
+ ret = cb(trip, data);
if (ret)
return ret;
}
@@ -27,6 +26,20 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
}
EXPORT_SYMBOL_GPL(for_each_thermal_trip);
+int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
+ int (*cb)(struct thermal_trip *, void *),
+ void *data)
+{
+ int ret;
+
+ mutex_lock(&tz->lock);
+ ret = for_each_thermal_trip(tz, cb, data);
+ mutex_unlock(&tz->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_for_each_trip);
+
int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
{
return tz->num_trips;
@@ -176,12 +189,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;
}