diff options
Diffstat (limited to 'drivers/thermal/gov_power_allocator.c')
| -rw-r--r-- | drivers/thermal/gov_power_allocator.c | 52 | 
1 files changed, 23 insertions, 29 deletions
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 2d1aeaba38a8..0eaf1527d3e3 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -8,7 +8,6 @@  #define pr_fmt(fmt) "Power allocator: " fmt -#include <linux/rculist.h>  #include <linux/slab.h>  #include <linux/thermal.h> @@ -125,16 +124,15 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,  				   u32 sustainable_power, int trip_switch_on,  				   int control_temp)  { +	struct thermal_trip trip; +	u32 temperature_threshold = control_temp;  	int ret; -	int switch_on_temp; -	u32 temperature_threshold;  	s32 k_i; -	ret = tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); -	if (ret) -		switch_on_temp = 0; +	ret = __thermal_zone_get_trip(tz, trip_switch_on, &trip); +	if (!ret) +		temperature_threshold -= trip.temperature; -	temperature_threshold = control_temp - switch_on_temp;  	/*  	 * estimate_pid_constants() tries to find appropriate default  	 * values for thermal zones that don't provide them. If a @@ -520,10 +518,10 @@ static void get_governor_trips(struct thermal_zone_device *tz,  	last_passive = INVALID_TRIP;  	for (i = 0; i < tz->num_trips; i++) { -		enum thermal_trip_type type; +		struct thermal_trip trip;  		int ret; -		ret = tz->ops->get_trip_type(tz, i, &type); +		ret = __thermal_zone_get_trip(tz, i, &trip);  		if (ret) {  			dev_warn(&tz->device,  				 "Failed to get trip point %d type: %d\n", i, @@ -531,14 +529,14 @@ static void get_governor_trips(struct thermal_zone_device *tz,  			continue;  		} -		if (type == THERMAL_TRIP_PASSIVE) { +		if (trip.type == THERMAL_TRIP_PASSIVE) {  			if (!found_first_passive) {  				params->trip_switch_on = i;  				found_first_passive = true;  			} else  {  				last_passive = i;  			} -		} else if (type == THERMAL_TRIP_ACTIVE) { +		} else if (trip.type == THERMAL_TRIP_ACTIVE) {  			last_active = i;  		} else {  			break; @@ -633,7 +631,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)  {  	int ret;  	struct power_allocator_params *params; -	int control_temp; +	struct thermal_trip trip;  	ret = check_power_actors(tz);  	if (ret) @@ -659,13 +657,12 @@ static int power_allocator_bind(struct thermal_zone_device *tz)  	get_governor_trips(tz, params);  	if (tz->num_trips > 0) { -		ret = tz->ops->get_trip_temp(tz, -					params->trip_max_desired_temperature, -					&control_temp); +		ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, +					      &trip);  		if (!ret)  			estimate_pid_constants(tz, tz->tzp->sustainable_power,  					       params->trip_switch_on, -					       control_temp); +					       trip.temperature);  	}  	reset_pid_controller(params); @@ -695,11 +692,11 @@ 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) +static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_id)  { -	int ret; -	int switch_on_temp, control_temp;  	struct power_allocator_params *params = tz->governor_data; +	struct thermal_trip trip; +	int ret;  	bool update;  	lockdep_assert_held(&tz->lock); @@ -708,13 +705,12 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)  	 * We get called for every trip point but we only need to do  	 * our calculations once  	 */ -	if (trip != params->trip_max_desired_temperature) +	if (trip_id != params->trip_max_desired_temperature)  		return 0; -	ret = tz->ops->get_trip_temp(tz, params->trip_switch_on, -				     &switch_on_temp); -	if (!ret && (tz->temperature < switch_on_temp)) { -		update = (tz->last_temperature >= switch_on_temp); +	ret = __thermal_zone_get_trip(tz, params->trip_switch_on, &trip); +	if (!ret && (tz->temperature < trip.temperature)) { +		update = (tz->last_temperature >= trip.temperature);  		tz->passive = 0;  		reset_pid_controller(params);  		allow_maximum_power(tz, update); @@ -723,16 +719,14 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)  	tz->passive = 1; -	ret = tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature, -				&control_temp); +	ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, &trip);  	if (ret) { -		dev_warn(&tz->device, -			 "Failed to get the maximum desired temperature: %d\n", +		dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d\n",  			 ret);  		return ret;  	} -	return allocate_power(tz, control_temp); +	return allocate_power(tz, trip.temperature);  }  static struct thermal_governor thermal_gov_power_allocator = {  |