Skip to contentSkip to conversation

power: regulator: fix autoset error handling

PATCH New John Keeping 1 participant 1 message Sep 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/power/regulator/regulator-uclass.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/power/regulator/regulator-uclass.c +7 -1
index aca00e56bb..d608f7c236 100644
@@ -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;
 	}
 
Signature · 1 line
2.37.3