regulator: handle different error codes in regulator_set_enable_if_allowed

The regulator core can return different codes which are not considered
a real error for this function.
Return success in such cases.

Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
This commit is contained in:
Eugen Hristev 2023-04-19 16:45:26 +03:00 committed by Jaehoon Chung
parent 29fca9f23a
commit 8202bc2945

View file

@ -197,6 +197,12 @@ int regulator_set_enable_if_allowed(struct udevice *dev, bool enable)
ret = regulator_set_enable(dev, enable);
if (ret == -ENOSYS || ret == -EACCES)
return 0;
/* if we want to disable but it's in use by someone else */
if (!enable && ret == -EBUSY)
return 0;
/* if it's already enabled/disabled */
if (ret == -EALREADY)
return 0;
return ret;
}