From: Rafael J. Wysocki Date: Mon, 29 Jul 2024 15:58:56 +0000 (+0200) Subject: thermal: qcom: Use thermal_zone_get_crit_temp() in qpnp_tm_init() X-Git-Tag: v6.12-rc1~216^2~2^2~20^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab446887ea7753e712cd3b6f54e5786bbb7b1e33;p=thirdparty%2Fkernel%2Flinux.git thermal: qcom: Use thermal_zone_get_crit_temp() in qpnp_tm_init() Modify qpnp_tm_init() to use thermal_zone_get_crit_temp() to get the critical trip temperature instead of iterating over trip indices and using thermal_zone_get_trip() to get a struct thermal_trip pointer from a trip index until it finds the critical one. Signed-off-by: Rafael J. Wysocki Reviewed-by: Lukasz Luba Link: https://patch.msgid.link/7712228.EvYhyI6sBW@rjwysocki.net --- diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c index 96daad28b0c04..c2d59cbfaea91 100644 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c @@ -291,24 +291,6 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data) return IRQ_HANDLED; } -static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip) -{ - struct thermal_trip trip; - int i, ret; - - for (i = 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) { - - ret = thermal_zone_get_trip(chip->tz_dev, i, &trip); - if (ret) - continue; - - if (trip.type == THERMAL_TRIP_CRITICAL) - return trip.temperature; - } - - return THERMAL_TEMP_INVALID; -} - /* * This function initializes the internal temp value based on only the * current thermal stage and threshold. Setup threshold control and @@ -343,7 +325,9 @@ static int qpnp_tm_init(struct qpnp_tm_chip *chip) mutex_unlock(&chip->lock); - crit_temp = qpnp_tm_get_critical_trip_temp(chip); + ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp); + if (ret) + crit_temp = THERMAL_TEMP_INVALID; mutex_lock(&chip->lock);