From: Rafael J. Wysocki Date: Fri, 2 Aug 2024 11:41:02 +0000 (+0200) Subject: thermal: hisi: Use thermal_zone_for_each_trip() in hisi_thermal_register_sensor() X-Git-Tag: v6.12-rc1~216^2~2^2~20^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ac1503cffd84aa7a6e699426de3e6308c9c34b6;p=thirdparty%2Fkernel%2Flinux.git thermal: hisi: Use thermal_zone_for_each_trip() in hisi_thermal_register_sensor() Modify hisi_thermal_register_sensor() to use thermal_zone_for_each_trip() for walking trip points instead of iterating over trip indices and using thermal_zone_get_trip() to get a struct thermal_trip pointer from a trip index. Signed-off-by: Rafael J. Wysocki Reviewed-by: Lukasz Luba Link: https://patch.msgid.link/1994088.PYKUYFuaPT@rjwysocki.net [ rjw: Dropped two unused local variables ] Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 0eb657db62e42..f1fe0f8ab04f1 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; }