Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/7712228.EvYhyI6sBW@rjwysocki.net

+3 -19
+3 -19
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
··· 291 291 return IRQ_HANDLED; 292 292 } 293 293 294 - static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip) 295 - { 296 - struct thermal_trip trip; 297 - int i, ret; 298 - 299 - for (i = 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) { 300 - 301 - ret = thermal_zone_get_trip(chip->tz_dev, i, &trip); 302 - if (ret) 303 - continue; 304 - 305 - if (trip.type == THERMAL_TRIP_CRITICAL) 306 - return trip.temperature; 307 - } 308 - 309 - return THERMAL_TEMP_INVALID; 310 - } 311 - 312 294 /* 313 295 * This function initializes the internal temp value based on only the 314 296 * current thermal stage and threshold. Setup threshold control and ··· 325 343 326 344 mutex_unlock(&chip->lock); 327 345 328 - crit_temp = qpnp_tm_get_critical_trip_temp(chip); 346 + ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp); 347 + if (ret) 348 + crit_temp = THERMAL_TEMP_INVALID; 329 349 330 350 mutex_lock(&chip->lock); 331 351