Skip to content

Commit 72fb849

Browse files
committed
thermal: core: Move some trip processing to thermal_trip_crossed()
Notice that some processing related to trip point crossing carried out in handle_thermal_trip() and thermal_zone_set_trip_temp() may as well be done in thermal_trip_crossed(), which allows code duplication to be reduced, so change the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/1982859.PYKUYFuaPT@rjwysocki.net
1 parent db0a46b commit 72fb849

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

drivers/thermal/thermal_core.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
460460
if (tz->temperature < trip->temperature - trip->hysteresis) {
461461
td->notify_temp = trip->temperature - trip->hysteresis;
462462
move_trip_to_sorted_list(td, way_down_list);
463-
464-
if (trip->type == THERMAL_TRIP_PASSIVE) {
465-
tz->passive--;
466-
WARN_ON(tz->passive < 0);
467-
}
468463
} else {
469464
td->threshold -= trip->hysteresis;
470465
}
@@ -478,12 +473,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
478473
move_trip_to_sorted_list(td, way_up_list);
479474

480475
td->threshold -= trip->hysteresis;
481-
482-
if (trip->type == THERMAL_TRIP_PASSIVE)
483-
tz->passive++;
484-
else if (trip->type == THERMAL_TRIP_CRITICAL ||
485-
trip->type == THERMAL_TRIP_HOT)
486-
handle_critical_trips(tz, trip);
487476
}
488477
}
489478

@@ -533,9 +522,19 @@ static void thermal_trip_crossed(struct thermal_zone_device *tz,
533522
const struct thermal_trip *trip = &td->trip;
534523

535524
if (crossed_up) {
525+
if (trip->type == THERMAL_TRIP_PASSIVE)
526+
tz->passive++;
527+
else if (trip->type == THERMAL_TRIP_CRITICAL ||
528+
trip->type == THERMAL_TRIP_HOT)
529+
handle_critical_trips(tz, trip);
530+
536531
thermal_notify_tz_trip_up(tz, trip);
537532
thermal_debug_tz_trip_up(tz, trip);
538533
} else {
534+
if (trip->type == THERMAL_TRIP_PASSIVE) {
535+
tz->passive--;
536+
WARN_ON(tz->passive < 0);
537+
}
539538
thermal_notify_tz_trip_down(tz, trip);
540539
thermal_debug_tz_trip_down(tz, trip);
541540
}

drivers/thermal/thermal_trip.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,13 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
108108
if (temp == THERMAL_TEMP_INVALID) {
109109
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
110110

111-
if (tz->temperature >= td->threshold) {
112-
/*
113-
* The trip has been crossed on the way up, so some
114-
* adjustments are needed to compensate for the lack
115-
* of it going forward.
116-
*/
117-
if (trip->type == THERMAL_TRIP_PASSIVE) {
118-
tz->passive--;
119-
WARN_ON_ONCE(tz->passive < 0);
120-
}
111+
/*
112+
* If the trip has been crossed on the way up, some adjustments
113+
* are needed to compensate for the lack of it going forward.
114+
*/
115+
if (tz->temperature >= td->threshold)
121116
thermal_zone_trip_down(tz, td);
122-
}
117+
123118
/*
124119
* Invalidate the threshold to avoid triggering a spurious
125120
* trip crossing notification when the trip becomes valid.

0 commit comments

Comments
 (0)