All of lore.kernel.org
 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

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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.