Skip to content

Commit 4aeea72

Browse files
Javier Martinez Canillassashalevin
authored andcommitted
regulator: Only enable disabled regulators on resume
[ Upstream commit 0548bf4 ] The _regulator_do_enable() call ought to be a no-op when called on an already-enabled regulator. However, as an optimization _regulator_enable() doesn't call _regulator_do_enable() on an already enabled regulator. That means we never test the case of calling _regulator_do_enable() during normal usage and there may be hidden bugs or warnings. We have seen warnings issued by the tps65090 driver and bugs when using the GPIO enable pin. Let's match the same optimization that _regulator_enable() in regulator_suspend_finish(). That may speed up suspend/resume and also avoids exposing hidden bugs. [Use much clearer commit message from Doug Anderson] Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 084968a commit 4aeea72

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎drivers/regulator/core.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,9 +3837,11 @@ int regulator_suspend_finish(void)
38373837
list_for_each_entry(rdev, &regulator_list, list) {
38383838
mutex_lock(&rdev->mutex);
38393839
if (rdev->use_count > 0 || rdev->constraints->always_on) {
3840-
error = _regulator_do_enable(rdev);
3841-
if (error)
3842-
ret = error;
3840+
if (!_regulator_is_enabled(rdev)) {
3841+
error = _regulator_do_enable(rdev);
3842+
if (error)
3843+
ret = error;
3844+
}
38433845
} else {
38443846
if (!have_full_constraints())
38453847
goto unlock;

0 commit comments

Comments
 (0)