int result;
lockdep_assert_held(&thermal_list_lock);
+ lockdep_assert_held(&tz->lock);
if (list_empty(&tz->node) || list_empty(&cdev->node))
return -EINVAL;
if (result)
goto remove_trip_file;
- mutex_lock(&tz->lock);
mutex_lock(&cdev->lock);
list_for_each_entry(pos, &tz->thermal_instances, tz_node)
if (pos->trip == trip && pos->cdev == cdev) {
thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV);
}
mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
if (!result)
return 0;
unsigned long upper, unsigned long lower,
unsigned int weight)
{
+ int ret;
+
if (trip_index < 0 || trip_index >= tz->num_trips)
return -EINVAL;
- return thermal_bind_cdev_to_trip(tz, &tz->trips[trip_index].trip, cdev,
- upper, lower, weight);
+ mutex_lock(&tz->lock);
+
+ ret = thermal_bind_cdev_to_trip(tz, &tz->trips[trip_index].trip, cdev,
+ upper, lower, weight);
+
+ mutex_unlock(&tz->lock);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device);
{
struct thermal_instance *pos, *next;
- mutex_lock(&tz->lock);
+ lockdep_assert_held(&tz->lock);
+
mutex_lock(&cdev->lock);
list_for_each_entry_safe(pos, next, &tz->thermal_instances, tz_node) {
if (pos->trip == trip && pos->cdev == cdev) {
thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV);
mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
goto unbind;
}
}
mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
return -ENODEV;
int trip_index,
struct thermal_cooling_device *cdev)
{
+ int ret;
+
if (trip_index < 0 || trip_index >= tz->num_trips)
return -EINVAL;
- return thermal_unbind_cdev_from_trip(tz, &tz->trips[trip_index].trip, cdev);
+ mutex_lock(&tz->lock);
+
+ ret = thermal_unbind_cdev_from_trip(tz, &tz->trips[trip_index].trip, cdev);
+
+ mutex_unlock(&tz->lock);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(thermal_zone_unbind_cooling_device);