linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: core: don't disable regulator if is_enabled return error.
@ 2020-11-06  6:48 Pi-Hsun Shih
  2020-11-10 21:38 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Pi-Hsun Shih @ 2020-11-06  6:48 UTC (permalink / raw)
  Cc: Pi-Hsun Shih, Liam Girdwood, Mark Brown,
	open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK

In regulator_late_cleanup when is_enabled failed, don't try to disable
the regulator since it would likely to fail too and causing confusing
error messages.

Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
---

This is encountered while using drivers/regulator/cros-ec-regulator.c.
Since the driver controls the regulator through ChromeOS EC host
commands, it is not available when doing suspend / resume.

But since the regulator_late_cleanup is delayed to 30 seconds after
boot, it is possible that the regulator_late_cleanup is run during
suspend / resume, which cause the is_enabled call to fail, and printing
out some confusing error messages later when trying to disable the
regulator and fail.

This commit attempts to address part of this issue by not trying to
disable the regulator if the is_enabled call failed.

---
 drivers/regulator/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a5ad553da8cd..70168f2a53ed 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5843,13 +5843,14 @@ static int regulator_late_cleanup(struct device *dev, void *data)
 	if (rdev->use_count)
 		goto unlock;
 
-	/* If we can't read the status assume it's on. */
+	/* If we can't read the status assume it's always on. */
 	if (ops->is_enabled)
 		enabled = ops->is_enabled(rdev);
 	else
 		enabled = 1;
 
-	if (!enabled)
+	/* But if reading the status failed, assume that it's off. */
+	if (enabled <= 0)
 		goto unlock;
 
 	if (have_full_constraints()) {

base-commit: 521b619acdc8f1f5acdac15b84f81fd9515b2aff
-- 
2.29.1.341.ge80a0c044ae-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: core: don't disable regulator if is_enabled return error.
  2020-11-06  6:48 [PATCH] regulator: core: don't disable regulator if is_enabled return error Pi-Hsun Shih
@ 2020-11-10 21:38 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-11-10 21:38 UTC (permalink / raw)
  To: Pi-Hsun Shih
  Cc: Liam Girdwood, open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK

On Fri, 6 Nov 2020 14:48:17 +0800, Pi-Hsun Shih wrote:
> In regulator_late_cleanup when is_enabled failed, don't try to disable
> the regulator since it would likely to fail too and causing confusing
> error messages.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: core: don't disable regulator if is_enabled return error.
      commit: c088a4985e5f6f6c2cbe5a6953357dfc30b7c57e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-10 21:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06  6:48 [PATCH] regulator: core: don't disable regulator if is_enabled return error Pi-Hsun Shih
2020-11-10 21:38 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).