===================================================================
@@ -789,6 +789,7 @@ int thermal_bind_cdev_to_trip(struct the
int result;
lockdep_assert_held(&thermal_list_lock);
+ lockdep_assert_held(&tz->lock);
if (list_empty(&tz->node) || list_empty(&cdev->node))
return -EINVAL;
@@ -851,7 +852,6 @@ int thermal_bind_cdev_to_trip(struct the
if (result)
goto remove_trip_file;
- mutex_lock(&tz->lock);
mutex_lock(&cdev->lock);
list_for_each_entry(instance, &td->thermal_instances, trip_node) {
@@ -868,7 +868,6 @@ int thermal_bind_cdev_to_trip(struct the
thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV);
mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
return 0;
@@ -892,11 +891,19 @@ int thermal_zone_bind_cooling_device(str
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);
@@ -919,7 +926,8 @@ int thermal_unbind_cdev_from_trip(struct
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
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, &td->thermal_instances, trip_node) {
@@ -930,13 +938,11 @@ int thermal_unbind_cdev_from_trip(struct
thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV);
mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
goto free;
}
}
mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
return -ENODEV;
@@ -954,10 +960,18 @@ int thermal_zone_unbind_cooling_device(s
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);
===================================================================
@@ -609,7 +609,7 @@ static int acpi_thermal_bind_unbind_cdev
.thermal = thermal, .cdev = cdev, .bind = bind
};
- return for_each_thermal_trip(thermal, bind_unbind_cdev_cb, &bd);
+ return thermal_zone_for_each_trip(thermal, bind_unbind_cdev_cb, &bd);
}
static int