Commit 8c35b1f4 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent fdcf70ed
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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(struct thermal_zone_device *tz, int trip_ind
 *     (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;
+3 −3
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static long get_target_state(struct thermal_zone_device *tz,
/**
 * 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 thermal_zone_device *tz,
 *	(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;
+2 −2
Original line number Diff line number Diff line
@@ -676,10 +676,10 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
	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);
+7 −5
Original line number Diff line number Diff line
@@ -68,15 +68,16 @@ static unsigned long get_target_state(struct thermal_instance *instance,
	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(struct thermal_zone_device *tz, int trip_id
/**
 * 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(struct thermal_zone_device *tz, int trip_id
 * 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;

+5 −3
Original line number Diff line number Diff line
@@ -25,11 +25,12 @@ static int user_space_bind(struct thermal_zone_device *tz)
/**
 * 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 thermal_zone_device *tz, int trip)

	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);
Loading