]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
regulator: handle different error codes in regulator_set_enable_if_allowed
authorEugen Hristev <eugen.hristev@collabora.com>
Wed, 19 Apr 2023 13:45:26 +0000 (16:45 +0300)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 4 Jul 2023 02:21:12 +0000 (11:21 +0900)
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>
drivers/power/regulator/regulator-uclass.c

index d608f7c23657337e299e7e6d1c10245d19fbc971..3a6ba69f6d5ff3495431353101d046ff8d67a526 100644 (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;
 }