Skip to content

Commit cd246fa

Browse files
committed
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>
1 parent 0c7d069 commit cd246fa

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

drivers/thermal/thermal_core.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,6 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
826826
const struct thermal_zone_params *tzp;
827827
struct thermal_zone_device *pos = NULL;
828828

829-
mutex_lock(&thermal_list_lock);
830-
831829
list_for_each_entry(pos, &thermal_tz_list, node) {
832830
if (!pos->tzp && !pos->ops->bind)
833831
continue;
@@ -854,8 +852,6 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
854852
tzp->tbp[i].weight);
855853
}
856854
}
857-
858-
mutex_unlock(&thermal_list_lock);
859855
}
860856

861857
/**
@@ -933,17 +929,17 @@ __thermal_cooling_device_register(struct device_node *np,
933929

934930
/* Add 'this' new cdev to the global cdev list */
935931
mutex_lock(&thermal_list_lock);
932+
936933
list_add(&cdev->node, &thermal_cdev_list);
937-
mutex_unlock(&thermal_list_lock);
938934

939935
/* Update binding information for 'this' new cdev */
940936
bind_cdev(cdev);
941937

942-
mutex_lock(&thermal_list_lock);
943938
list_for_each_entry(pos, &thermal_tz_list, node)
944939
if (atomic_cmpxchg(&pos->need_update, 1, 0))
945940
thermal_zone_device_update(pos,
946941
THERMAL_EVENT_UNSPECIFIED);
942+
947943
mutex_unlock(&thermal_list_lock);
948944

949945
return cdev;

0 commit comments

Comments
 (0)