Commit ff9b34b6 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Mark Brown

regulator: core: Keep regulators-list locked while traversing the list

It's unlikely that regulators may disappear/appear while regulators
debug-summary is being prepared, but let's be consistent and avoid that
situation.
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 089e2cc2
...@@ -4936,7 +4936,9 @@ void regulator_unregister(struct regulator_dev *rdev) ...@@ -4936,7 +4936,9 @@ void regulator_unregister(struct regulator_dev *rdev)
regulator_disable(rdev->supply); regulator_disable(rdev->supply);
regulator_put(rdev->supply); regulator_put(rdev->supply);
} }
mutex_lock(&regulator_list_mutex); mutex_lock(&regulator_list_mutex);
debugfs_remove_recursive(rdev->debugfs); debugfs_remove_recursive(rdev->debugfs);
flush_work(&rdev->disable_work.work); flush_work(&rdev->disable_work.work);
WARN_ON(rdev->open_count); WARN_ON(rdev->open_count);
...@@ -4944,8 +4946,9 @@ void regulator_unregister(struct regulator_dev *rdev) ...@@ -4944,8 +4946,9 @@ void regulator_unregister(struct regulator_dev *rdev)
unset_regulator_supplies(rdev); unset_regulator_supplies(rdev);
list_del(&rdev->list); list_del(&rdev->list);
regulator_ena_gpio_free(rdev); regulator_ena_gpio_free(rdev);
mutex_unlock(&regulator_list_mutex);
device_unregister(&rdev->dev); device_unregister(&rdev->dev);
mutex_unlock(&regulator_list_mutex);
} }
EXPORT_SYMBOL_GPL(regulator_unregister); EXPORT_SYMBOL_GPL(regulator_unregister);
...@@ -5278,6 +5281,8 @@ static void regulator_summary_lock(struct ww_acquire_ctx *ww_ctx) ...@@ -5278,6 +5281,8 @@ static void regulator_summary_lock(struct ww_acquire_ctx *ww_ctx)
struct regulator_dev *old_contended_rdev = NULL; struct regulator_dev *old_contended_rdev = NULL;
int err; int err;
mutex_lock(&regulator_list_mutex);
ww_acquire_init(ww_ctx, &regulator_ww_class); ww_acquire_init(ww_ctx, &regulator_ww_class);
do { do {
...@@ -5304,6 +5309,8 @@ static void regulator_summary_unlock(struct ww_acquire_ctx *ww_ctx) ...@@ -5304,6 +5309,8 @@ static void regulator_summary_unlock(struct ww_acquire_ctx *ww_ctx)
class_for_each_device(&regulator_class, NULL, NULL, class_for_each_device(&regulator_class, NULL, NULL,
regulator_summary_unlock_one); regulator_summary_unlock_one);
ww_acquire_fini(ww_ctx); ww_acquire_fini(ww_ctx);
mutex_unlock(&regulator_list_mutex);
} }
static int regulator_summary_show_roots(struct device *dev, void *data) static int regulator_summary_show_roots(struct device *dev, void *data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment