===================================================================
@@ -199,7 +199,8 @@ struct thermal_governor {
char name[THERMAL_NAME_LENGTH];
int (*bind_to_tz)(struct thermal_zone_device *tz);
void (*unbind_from_tz)(struct thermal_zone_device *tz);
- int (*throttle)(struct thermal_zone_device *tz, int trip);
+ int (*throttle)(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip);
struct list_head governor_list;
};
===================================================================
@@ -13,9 +13,10 @@
#include "thermal_core.h"
-static int thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_index)
+static int thermal_zone_trip_update(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
- const struct thermal_trip *trip = &tz->trips[trip_index];
+ int trip_index = thermal_zone_trip_id(tz, trip);
struct thermal_instance *instance;
if (!trip->hysteresis)
@@ -89,7 +90,8 @@ static int thermal_zone_trip_update(stru
* (trip_temp - hyst) so that the fan gets turned off again.
*
*/
-static int bang_bang_control(struct thermal_zone_device *tz, int trip)
+static int bang_bang_control(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
struct thermal_instance *instance;
int ret;
===================================================================
@@ -47,7 +47,7 @@ static long get_target_state(struct ther
/**
* fair_share_throttle - throttles devices associated with the given zone
* @tz: thermal_zone_device
- * @trip_index: trip point index
+ * @trip: trip point
*
* Throttling Logic: This uses three parameters to calculate the new
* throttle state of the cooling devices associated with the given zone.
@@ -63,9 +63,9 @@ static long get_target_state(struct ther
* (Heavily assumes the trip points are in ascending order)
* new_state of cooling device = P3 * P2 * P1
*/
-static int fair_share_throttle(struct thermal_zone_device *tz, int trip_index)
+static int fair_share_throttle(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
- const struct thermal_trip *trip = &tz->trips[trip_index];
struct thermal_instance *instance;
int total_weight = 0;
int total_instance = 0;
===================================================================
@@ -680,10 +680,10 @@ static void power_allocator_unbind(struc
tz->governor_data = NULL;
}
-static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_index)
+static int power_allocator_throttle(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
struct power_allocator_params *params = tz->governor_data;
- const struct thermal_trip *trip = &tz->trips[trip_index];
bool update;
lockdep_assert_held(&tz->lock);
===================================================================
@@ -68,15 +68,16 @@ static unsigned long get_target_state(st
return next_target;
}
-static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id)
+static void thermal_zone_trip_update(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
- const struct thermal_trip *trip = &tz->trips[trip_id];
+ int trip_id = thermal_zone_trip_id(tz, trip);
enum thermal_trend trend;
struct thermal_instance *instance;
bool throttle = false;
int old_target;
- trend = get_tz_trend(tz, trip_id);
+ trend = get_tz_trend(tz, trip);
if (tz->temperature >= trip->temperature) {
throttle = true;
@@ -120,7 +121,7 @@ static void thermal_zone_trip_update(str
/**
* step_wise_throttle - throttles devices associated with the given zone
* @tz: thermal_zone_device
- * @trip: trip point index
+ * @trip: trip point
*
* Throttling Logic: This uses the trend of the thermal zone to throttle.
* If the thermal zone is 'heating up' this throttles all the cooling
@@ -128,7 +129,8 @@ static void thermal_zone_trip_update(str
* step. If the zone is 'cooling down' it brings back the performance of
* the devices by one step.
*/
-static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
+static int step_wise_throttle(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
struct thermal_instance *instance;
===================================================================
@@ -22,9 +22,8 @@
#include "thermal_core.h"
#include "thermal_trace.h"
-int get_tz_trend(struct thermal_zone_device *tz, int trip_index)
+int get_tz_trend(struct thermal_zone_device *tz, const struct thermal_trip *trip)
{
- struct thermal_trip *trip = tz->trips ? &tz->trips[trip_index] : NULL;
enum thermal_trend trend;
if (tz->emul_temperature || !tz->ops->get_trend ||
===================================================================
@@ -70,7 +70,7 @@ static inline bool cdev_is_power_actor(s
void thermal_cdev_update(struct thermal_cooling_device *);
void __thermal_cdev_update(struct thermal_cooling_device *cdev);
-int get_tz_trend(struct thermal_zone_device *tz, int trip_index);
+int get_tz_trend(struct thermal_zone_device *tz, const struct thermal_trip *trip);
struct thermal_instance *
get_thermal_instance(struct thermal_zone_device *tz,
===================================================================
@@ -25,11 +25,12 @@ static int user_space_bind(struct therma
/**
* notify_user_space - Notifies user space about thermal events
* @tz: thermal_zone_device
- * @trip: trip point index
+ * @trip: trip point
*
* This function notifies the user space through UEvents.
*/
-static int notify_user_space(struct thermal_zone_device *tz, int trip)
+static int notify_user_space(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip)
{
char *thermal_prop[5];
int i;
@@ -38,7 +39,8 @@ static int notify_user_space(struct ther
thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", tz->type);
thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", tz->temperature);
- thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d", trip);
+ thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d",
+ thermal_zone_trip_id(tz, trip));
thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", tz->notify_event);
thermal_prop[4] = NULL;
kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
===================================================================
@@ -307,7 +307,8 @@ static void monitor_thermal_zone(struct
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
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(str
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
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);
}