[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201106064817.3290927-1-pihsun@chromium.org>
Date: Fri, 6 Nov 2020 14:48:17 +0800
From: Pi-Hsun Shih <pihsun@...omium.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Pi-Hsun Shih <pihsun@...omium.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
linux-kernel@...r.kernel.org (open list:VOLTAGE AND CURRENT REGULATOR
FRAMEWORK)
Subject: [PATCH] regulator: core: don't disable regulator if is_enabled return error.
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@...omium.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
Powered by blists - more mailing lists