summaryrefslogtreecommitdiff
path: root/drivers/thermal/hisi_thermal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/hisi_thermal.c')
-rw-r--r--drivers/thermal/hisi_thermal.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 0eb657db62e4..f1fe0f8ab04f 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -465,11 +465,22 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
return IRQ_HANDLED;
}
+static int hisi_trip_walk_cb(struct thermal_trip *trip, void *arg)
+{
+ struct hisi_thermal_sensor *sensor = arg;
+
+ if (trip->type != THERMAL_TRIP_PASSIVE)
+ return 0;
+
+ sensor->thres_temp = trip->temperature;
+ /* Return nonzero to terminate the search. */
+ return 1;
+}
+
static int hisi_thermal_register_sensor(struct platform_device *pdev,
struct hisi_thermal_sensor *sensor)
{
- int ret, i;
- struct thermal_trip trip;
+ int ret;
sensor->tzd = devm_thermal_of_zone_register(&pdev->dev,
sensor->id, sensor,
@@ -482,15 +493,7 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev,
return ret;
}
- for (i = 0; i < thermal_zone_get_num_trips(sensor->tzd); i++) {
-
- thermal_zone_get_trip(sensor->tzd, i, &trip);
-
- if (trip.type == THERMAL_TRIP_PASSIVE) {
- sensor->thres_temp = trip.temperature;
- break;
- }
- }
+ thermal_zone_for_each_trip(sensor->tzd, hisi_trip_walk_cb, sensor);
return 0;
}