trip, trip_temp, tz->temperature,
trip_hyst);
- mutex_lock(&tz->lock);
-
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}
-
- mutex_unlock(&tz->lock);
}
/**
{
struct thermal_instance *instance;
- thermal_zone_trip_update(tz, trip);
-
mutex_lock(&tz->lock);
+ thermal_zone_trip_update(tz, trip);
+
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);
int i, num_actors, total_weight, ret = 0;
int trip_max_desired_temperature = params->trip_max_desired_temperature;
- mutex_lock(&tz->lock);
-
num_actors = 0;
total_weight = 0;
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
}
}
- if (!num_actors) {
- ret = -ENODEV;
- goto unlock;
- }
+ if (!num_actors)
+ return -ENODEV;
/*
* We need to allocate five arrays of the same size:
BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power));
BUILD_BUG_ON(sizeof(*req_power) != sizeof(*weighted_req_power));
req_power = kcalloc(num_actors * 5, sizeof(*req_power), GFP_KERNEL);
- if (!req_power) {
- ret = -ENOMEM;
- goto unlock;
- }
+ if (!req_power)
+ return -ENOMEM;
max_power = &req_power[num_actors];
granted_power = &req_power[2 * num_actors];
control_temp - tz->temperature);
kfree(req_power);
-unlock:
- mutex_unlock(&tz->lock);
return ret;
}
struct power_allocator_params *params = tz->governor_data;
u32 req_power;
- mutex_lock(&tz->lock);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
struct thermal_cooling_device *cdev = instance->cdev;
mutex_unlock(&instance->cdev->lock);
}
- mutex_unlock(&tz->lock);
}
/**
static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
{
- int ret;
+ int ret = 0;
int switch_on_temp, control_temp;
struct power_allocator_params *params = tz->governor_data;
bool update;
+ mutex_lock(&tz->lock);
+
/*
* We get called for every trip point but we only need to do
* our calculations once
*/
if (trip != params->trip_max_desired_temperature)
- return 0;
+ goto out;
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
&switch_on_temp);
tz->passive = 0;
reset_pid_controller(params);
allow_maximum_power(tz, update);
- return 0;
+ goto out;
}
tz->passive = 1;
dev_warn(&tz->device,
"Failed to get the maximum desired temperature: %d\n",
ret);
- return ret;
+ goto out;
}
- return allocate_power(tz, control_temp);
+ ret = allocate_power(tz, control_temp);
+
+ mutex_unlock(&tz->lock);
+out:
+ return ret;
}
static struct thermal_governor thermal_gov_power_allocator = {
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
trip, trip_type, trip_temp, trend, throttle);
- mutex_lock(&tz->lock);
-
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}
-
- mutex_unlock(&tz->lock);
}
/**
{
struct thermal_instance *instance;
- thermal_zone_trip_update(tz, trip);
-
mutex_lock(&tz->lock);
+ thermal_zone_trip_update(tz, trip);
+
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);