Skip to content

Commit

Permalink
regulator: Only enable disabled regulators on resume
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Javier Martinez Canillas authored and Mark Brown committed Mar 8, 2015
1 parent c517d83 commit 0548bf4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3807,9 +3807,11 @@ int regulator_suspend_finish(void)
list_for_each_entry(rdev, &regulator_list, list) {
mutex_lock(&rdev->mutex);
if (rdev->use_count > 0 || rdev->constraints->always_on) {
error = _regulator_do_enable(rdev);
if (error)
ret = error;
if (!_regulator_is_enabled(rdev)) {
error = _regulator_do_enable(rdev);
if (error)
ret = error;
}
} else {
if (!have_full_constraints())
goto unlock;
Expand Down

0 comments on commit 0548bf4

Please sign in to comment.