Skip to content

Commit c690dce

Browse files
committed
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Lukasz Luba <[email protected]>
1 parent 6d153f5 commit c690dce

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/thermal/thermal_core.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,17 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
868868
return result;
869869
}
870870

871+
static void thermal_instance_delete(struct thermal_instance *instance)
872+
{
873+
list_del(&instance->trip_node);
874+
875+
mutex_lock(&instance->cdev->lock);
876+
877+
list_del(&instance->cdev_node);
878+
879+
mutex_unlock(&instance->cdev->lock);
880+
}
881+
871882
/**
872883
* thermal_unbind_cdev_from_trip - unbind a cooling device from a thermal zone.
873884
* @tz: pointer to a struct thermal_zone_device.
@@ -884,16 +895,12 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
884895
{
885896
struct thermal_instance *pos, *next;
886897

887-
mutex_lock(&cdev->lock);
888898
list_for_each_entry_safe(pos, next, &td->thermal_instances, trip_node) {
889899
if (pos->cdev == cdev) {
890-
list_del(&pos->trip_node);
891-
list_del(&pos->cdev_node);
892-
mutex_unlock(&cdev->lock);
900+
thermal_instance_delete(pos);
893901
goto unbind;
894902
}
895903
}
896-
mutex_unlock(&cdev->lock);
897904

898905
return;
899906

0 commit comments

Comments
 (0)