Skip to content

Commit f99c1b8

Browse files
committed
thermal: core: Rewrite comments in handle_thermal_trip()
Make the comments regarding trip crossing and threshold updates in handle_thermal_trip() slightly more clear. No functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent b1ae92d commit f99c1b8

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

drivers/thermal/thermal_core.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,23 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
368368
if (trip->temperature == THERMAL_TEMP_INVALID)
369369
return;
370370

371+
/*
372+
* If the trip temperature or hysteresis has been updated recently,
373+
* the threshold needs to be computed again using the new values.
374+
* However, its initial value still reflects the old ones and that
375+
* is what needs to be compared with the previous zone temperature
376+
* to decide which action to take.
377+
*/
371378
if (tz->last_temperature == THERMAL_TEMP_INVALID) {
372379
/* Initialization. */
373380
td->threshold = trip->temperature;
374381
if (tz->temperature >= td->threshold)
375382
td->threshold -= trip->hysteresis;
376383
} else if (tz->last_temperature < td->threshold) {
377384
/*
378-
* The trip threshold is equal to the trip temperature, unless
379-
* the latter has changed in the meantime. In either case,
380-
* the trip is crossed if the current zone temperature is at
381-
* least equal to its temperature, but otherwise ensure that
382-
* the threshold and the trip temperature will be equal.
385+
* There is no mitigation under way, so it needs to be started
386+
* if the zone temperature exceeds the trip one. The new
387+
* threshold is then set to the low temperature of the trip.
383388
*/
384389
if (tz->temperature >= trip->temperature) {
385390
thermal_notify_tz_trip_up(tz, trip);
@@ -390,14 +395,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
390395
}
391396
} else {
392397
/*
393-
* The previous zone temperature was above or equal to the trip
394-
* threshold, which would be equal to the "low temperature" of
395-
* the trip (its temperature minus its hysteresis), unless the
396-
* trip temperature or hysteresis had changed. In either case,
397-
* the trip is crossed if the current zone temperature is below
398-
* the low temperature of the trip, but otherwise ensure that
399-
* the trip threshold will be equal to the low temperature of
400-
* the trip.
398+
* Mitigation is under way, so it needs to stop if the zone
399+
* temperature falls below the low temperature of the trip.
400+
* In that case, the trip temperature becomes the new threshold.
401401
*/
402402
if (tz->temperature < trip->temperature - trip->hysteresis) {
403403
thermal_notify_tz_trip_down(tz, trip);

0 commit comments

Comments
 (0)