summaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_core.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-10-12 21:34:50 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-10-20 20:26:37 +0300
commit8c35b1f472533b0df1b8f1f1afcaf4395cdb2256 (patch)
tree00be096e40c553e3912fbc9ad62190d555b41421 /drivers/thermal/thermal_core.c
parentfdcf70ed4e1606cd5a5a48f666583053ae4c3978 (diff)
downloadlinux-8c35b1f472533b0df1b8f1f1afcaf4395cdb2256.tar.xz
thermal: core: Pass trip pointer to governor throttle callback
Modify the governor .throttle() callback definition so that it takes a trip pointer instead of a trip index as its second argument, adjust the governors accordingly and update the core code invoking .throttle(). This causes the governors to become independent of the representation of the list of trips in the thermal zone structure. This change is not expected to alter the general functionality. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/thermal/thermal_core.c')
-rw-r--r--drivers/thermal/thermal_core.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 2b345f25dfa4..9c17d35ccbbd 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -307,7 +307,8 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
}
-static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
+static void handle_non_critical_trips(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
tz->governor ? tz->governor->throttle(tz, trip) :
def_governor->throttle(tz, trip);
@@ -329,44 +330,43 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz)
EXPORT_SYMBOL(thermal_zone_device_critical);
static void handle_critical_trips(struct thermal_zone_device *tz,
- int trip, int trip_temp, enum thermal_trip_type trip_type)
+ const struct thermal_trip *trip)
{
/* If we have not crossed the trip_temp, we do not care. */
- if (trip_temp <= 0 || tz->temperature < trip_temp)
+ if (trip->temperature <= 0 || tz->temperature < trip->temperature)
return;
- trace_thermal_zone_trip(tz, trip, trip_type);
+ trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
- if (trip_type == THERMAL_TRIP_HOT && tz->ops->hot)
- tz->ops->hot(tz);
- else if (trip_type == THERMAL_TRIP_CRITICAL)
+ if (trip->type == THERMAL_TRIP_CRITICAL)
tz->ops->critical(tz);
+ else if (tz->ops->hot)
+ tz->ops->hot(tz);
}
-static void handle_thermal_trip(struct thermal_zone_device *tz, int trip_id)
+static void handle_thermal_trip(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
- struct thermal_trip trip;
-
- __thermal_zone_get_trip(tz, trip_id, &trip);
-
- if (trip.temperature == THERMAL_TEMP_INVALID)
+ if (trip->temperature == THERMAL_TEMP_INVALID)
return;
if (tz->last_temperature != THERMAL_TEMP_INVALID) {
- if (tz->last_temperature < trip.temperature &&
- tz->temperature >= trip.temperature)
- thermal_notify_tz_trip_up(tz->id, trip_id,
+ if (tz->last_temperature < trip->temperature &&
+ tz->temperature >= trip->temperature)
+ thermal_notify_tz_trip_up(tz->id,
+ thermal_zone_trip_id(tz, trip),
tz->temperature);
- if (tz->last_temperature >= trip.temperature &&
- tz->temperature < (trip.temperature - trip.hysteresis))
- thermal_notify_tz_trip_down(tz->id, trip_id,
+ if (tz->last_temperature >= trip->temperature &&
+ tz->temperature < trip->temperature - trip->hysteresis)
+ thermal_notify_tz_trip_down(tz->id,
+ thermal_zone_trip_id(tz, trip),
tz->temperature);
}
- if (trip.type == THERMAL_TRIP_CRITICAL || trip.type == THERMAL_TRIP_HOT)
- handle_critical_trips(tz, trip_id, trip.temperature, trip.type);
+ if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
+ handle_critical_trips(tz, trip);
else
- handle_non_critical_trips(tz, trip_id);
+ handle_non_critical_trips(tz, trip);
}
static void update_temperature(struct thermal_zone_device *tz)
@@ -403,7 +403,7 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
void __thermal_zone_device_update(struct thermal_zone_device *tz,
enum thermal_notify_event event)
{
- int count;
+ const struct thermal_trip *trip;
if (atomic_read(&in_suspend))
return;
@@ -422,8 +422,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
tz->notify_event = event;
- for (count = 0; count < tz->num_trips; count++)
- handle_thermal_trip(tz, count);
+ for_each_trip(tz, trip)
+ handle_thermal_trip(tz, trip);
monitor_thermal_zone(tz);
}