diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2023-03-22 22:34:12 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2023-04-03 21:40:21 +0300 |
commit | cd246fa969ec9f31a244f4056361c694ca8d99d3 (patch) | |
tree | 8330313458dd13d5e240ec26608a14e91edcf373 /drivers/thermal | |
parent | 0c7d069297a098af05f9ecc130c4d6f1973bfed7 (diff) | |
download | linux-cd246fa969ec9f31a244f4056361c694ca8d99d3.tar.xz |
thermal: core: Clean up thermal_list_lock locking
Once thermal_list_lock has been acquired in
__thermal_cooling_device_register(), it is not necessary to drop it
and take it again until all of the thermal zones have been updated,
so change the code accordingly.
No expected functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/thermal_core.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 9cb0a78636e3..94765b008393 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -826,8 +826,6 @@ static void bind_cdev(struct thermal_cooling_device *cdev) const struct thermal_zone_params *tzp; struct thermal_zone_device *pos = NULL; - mutex_lock(&thermal_list_lock); - list_for_each_entry(pos, &thermal_tz_list, node) { if (!pos->tzp && !pos->ops->bind) continue; @@ -854,8 +852,6 @@ static void bind_cdev(struct thermal_cooling_device *cdev) tzp->tbp[i].weight); } } - - mutex_unlock(&thermal_list_lock); } /** @@ -933,17 +929,17 @@ __thermal_cooling_device_register(struct device_node *np, /* Add 'this' new cdev to the global cdev list */ mutex_lock(&thermal_list_lock); + list_add(&cdev->node, &thermal_cdev_list); - mutex_unlock(&thermal_list_lock); /* Update binding information for 'this' new cdev */ bind_cdev(cdev); - mutex_lock(&thermal_list_lock); list_for_each_entry(pos, &thermal_tz_list, node) if (atomic_cmpxchg(&pos->need_update, 1, 0)) thermal_zone_device_update(pos, THERMAL_EVENT_UNSPECIFIED); + mutex_unlock(&thermal_list_lock); return cdev; |