aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keeping <john@metanate.com>2022-09-08 12:38:35 +0100
committerJaehoon Chung <jh80.chung@samsung.com>2022-10-26 11:47:12 +0900
commit8edf7ac09fb6ee1ff445463be59c4a08ea91a0ae (patch)
tree66c5a8911e07e89911351693f6694c7101bccfdd
parentf9d16f2c0daf68dcb963c08c927f5f0a07cf75e4 (diff)
power: regulator: fix autoset error handling
If a regulator does not support .set_suspend_enable or .set_suspend_value then ret is set to ENOSYS early in the function. The most serious impact of this is that when no automatic setting of voltage is needed then the final regulator_set_enable() is skipped because ret has not been cleared. It seems that the error handling for regulator_set_suspend_value() is also wrong as if this succeeds then the normal boot-on checks are still required, and again ENOSYS needs special treatment here. Fixes: 11406b8f7e ("dm: regulator: support regulator more state") Signed-off-by: John Keeping <john@metanate.com>
-rw-r--r--drivers/power/regulator/regulator-uclass.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index aca00e56bb..d608f7c236 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -288,9 +288,15 @@ int regulator_autoset(struct udevice *dev)
uc_pdata = dev_get_uclass_plat(dev);
ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on);
+ if (ret == -ENOSYS)
+ ret = 0;
+
if (!ret && uc_pdata->suspend_on) {
ret = regulator_set_suspend_value(dev, uc_pdata->suspend_uV);
- if (!ret)
+ if (ret == -ENOSYS)
+ ret = 0;
+
+ if (ret)
return ret;
}