summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-10-11 00:15:22 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-10-23 11:57:04 +0200
commitc690dce5dceef1d2818c52f3df2d3511f028632f (patch)
tree6aa1c4d1784ba3eda551eef83cb58cb9bb177be3 /drivers/thermal
parentthermal: core: Introduce thermal_instance_add() (diff)
downloadlinux-c690dce5dceef1d2818c52f3df2d3511f028632f.tar.xz
linux-c690dce5dceef1d2818c52f3df2d3511f028632f.zip
thermal: core: Introduce thermal_instance_delete()
It is not necessary to walk the thermal_instances list in a trip descriptor under a cooling device lock, so acquire that lock only for deleting the given thermal instance from the list of thermal instances in the given cdev. Moreover, in analogy with the previous change that introduced thermal_instance_add(), put the code deleting the given thermal instance from the lists it is on into a separate new function called thermal_instance_delete(). No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3275745.5fSG56mABF@rjwysocki.net Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_core.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index ae424eef4574..ab0c7c6396c0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -868,6 +868,17 @@ free_mem:
return result;
}
+static void thermal_instance_delete(struct thermal_instance *instance)
+{
+ list_del(&instance->trip_node);
+
+ mutex_lock(&instance->cdev->lock);
+
+ list_del(&instance->cdev_node);
+
+ mutex_unlock(&instance->cdev->lock);
+}
+
/**
* thermal_unbind_cdev_from_trip - unbind a cooling device from a thermal zone.
* @tz: pointer to a struct thermal_zone_device.
@@ -884,16 +895,12 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
{
struct thermal_instance *pos, *next;
- mutex_lock(&cdev->lock);
list_for_each_entry_safe(pos, next, &td->thermal_instances, trip_node) {
if (pos->cdev == cdev) {
- list_del(&pos->trip_node);
- list_del(&pos->cdev_node);
- mutex_unlock(&cdev->lock);
+ thermal_instance_delete(pos);
goto unbind;
}
}
- mutex_unlock(&cdev->lock);
return;