summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2017-09-04 18:45:37 +0200
committerMark Brown <broonie@kernel.org>2017-09-04 18:45:37 +0200
commit0bbc0a0a0270ecb1cc8726c6ea663320b4b5e551 (patch)
treee935e737ad8d99a6dc45716d5a8f7b8e261f6a77 /drivers
parentLinux 4.13 (diff)
parentregulator: core: fix a possible race in disable_work handling (diff)
downloadlinux-0bbc0a0a0270ecb1cc8726c6ea663320b4b5e551.tar.xz
linux-0bbc0a0a0270ecb1cc8726c6ea663320b4b5e551.zip
Merge remote-tracking branch 'regulator/fix/core' into regulator-linus
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/core.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e567fa54980b..9f4d484eb25d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2396,6 +2396,14 @@ static void regulator_disable_work(struct work_struct *work)
count = rdev->deferred_disables;
rdev->deferred_disables = 0;
+ /*
+ * Workqueue functions queue the new work instance while the previous
+ * work instance is being processed. Cancel the queued work instance
+ * as the work instance under processing does the job of the queued
+ * work instance.
+ */
+ cancel_delayed_work(&rdev->disable_work);
+
for (i = 0; i < count; i++) {
ret = _regulator_disable(rdev);
if (ret != 0)
@@ -2439,10 +2447,10 @@ int regulator_disable_deferred(struct regulator *regulator, int ms)
mutex_lock(&rdev->mutex);
rdev->deferred_disables++;
+ mod_delayed_work(system_power_efficient_wq, &rdev->disable_work,
+ msecs_to_jiffies(ms));
mutex_unlock(&rdev->mutex);
- queue_delayed_work(system_power_efficient_wq, &rdev->disable_work,
- msecs_to_jiffies(ms));
return 0;
}
EXPORT_SYMBOL_GPL(regulator_disable_deferred);