summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-10-16 13:29:14 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-10-24 17:15:07 +0200
commit72fb849f77d94d8f60cbb2d7251ac26de8c9e090 (patch)
treebe6856eff3beca2c6abe0b237ba1f0d7ae95bbc1
parentdb0a46b60033a60d54e6a5b1e760aeda01bb116c (diff)
downloadlwn-72fb849f77d94d8f60cbb2d7251ac26de8c9e090.tar.gz
lwn-72fb849f77d94d8f60cbb2d7251ac26de8c9e090.zip
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
-rw-r--r--drivers/thermal/thermal_core.c21
-rw-r--r--drivers/thermal/thermal_trip.c17
2 files changed, 16 insertions, 22 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c8144a6bb001..277076658ccd 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -460,11 +460,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
if (tz->temperature < trip->temperature - trip->hysteresis) {
td->notify_temp = trip->temperature - trip->hysteresis;
move_trip_to_sorted_list(td, way_down_list);
-
- if (trip->type == THERMAL_TRIP_PASSIVE) {
- tz->passive--;
- WARN_ON(tz->passive < 0);
- }
} else {
td->threshold -= trip->hysteresis;
}
@@ -478,12 +473,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
move_trip_to_sorted_list(td, way_up_list);
td->threshold -= trip->hysteresis;
-
- if (trip->type == THERMAL_TRIP_PASSIVE)
- tz->passive++;
- else if (trip->type == THERMAL_TRIP_CRITICAL ||
- trip->type == THERMAL_TRIP_HOT)
- handle_critical_trips(tz, trip);
}
}
@@ -533,9 +522,19 @@ static void thermal_trip_crossed(struct thermal_zone_device *tz,
const struct thermal_trip *trip = &td->trip;
if (crossed_up) {
+ if (trip->type == THERMAL_TRIP_PASSIVE)
+ tz->passive++;
+ else if (trip->type == THERMAL_TRIP_CRITICAL ||
+ trip->type == THERMAL_TRIP_HOT)
+ handle_critical_trips(tz, trip);
+
thermal_notify_tz_trip_up(tz, trip);
thermal_debug_tz_trip_up(tz, trip);
} else {
+ if (trip->type == THERMAL_TRIP_PASSIVE) {
+ tz->passive--;
+ WARN_ON(tz->passive < 0);
+ }
thermal_notify_tz_trip_down(tz, trip);
thermal_debug_tz_trip_down(tz, trip);
}
diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c
index 37db75fb959f..5cafea8dc804 100644
--- a/drivers/thermal/thermal_trip.c
+++ b/drivers/thermal/thermal_trip.c
@@ -108,18 +108,13 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
if (temp == THERMAL_TEMP_INVALID) {
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
- if (tz->temperature >= td->threshold) {
- /*
- * The trip has been crossed on the way up, so some
- * adjustments are needed to compensate for the lack
- * of it going forward.
- */
- if (trip->type == THERMAL_TRIP_PASSIVE) {
- tz->passive--;
- WARN_ON_ONCE(tz->passive < 0);
- }
+ /*
+ * If the trip has been crossed on the way up, some adjustments
+ * are needed to compensate for the lack of it going forward.
+ */
+ if (tz->temperature >= td->threshold)
thermal_zone_trip_down(tz, td);
- }
+
/*
* Invalidate the threshold to avoid triggering a spurious
* trip crossing notification when the trip becomes valid.