Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a335634 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "regulator: core: fix a possible race in disable_work handling"

parents e19174d2 089d5aab
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -2408,6 +2408,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)
@@ -2451,10 +2459,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);