]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: dwc2: Use regulator_set_enable_if_allowed
authorJonas Karlman <jonas@kwiboo.se>
Wed, 19 Jul 2023 21:20:56 +0000 (21:20 +0000)
committerTom Rini <trini@konsulko.com>
Mon, 14 Aug 2023 13:14:41 +0000 (09:14 -0400)
With the commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable may be EALREADY or
EBUSY for fixed/gpio regulators.

Change to use the more relaxed regulator_set_enable_if_allowed to
continue if regulator already was enabled or disabled.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org> # rockpro64-rk3399
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/usb/host/dwc2.c

index 9818f9be94e010398e5a3b5986b127e3ebf3972c..637eb2dd06f5394d491a11cf5d6675219ca07339 100644 (file)
@@ -194,8 +194,8 @@ static int dwc_vbus_supply_init(struct udevice *dev)
                return 0;
        }
 
-       ret = regulator_set_enable(priv->vbus_supply, true);
-       if (ret) {
+       ret = regulator_set_enable_if_allowed(priv->vbus_supply, true);
+       if (ret && ret != -ENOSYS) {
                dev_err(dev, "Error enabling vbus supply\n");
                return ret;
        }
@@ -208,12 +208,10 @@ static int dwc_vbus_supply_exit(struct udevice *dev)
        struct dwc2_priv *priv = dev_get_priv(dev);
        int ret;
 
-       if (priv->vbus_supply) {
-               ret = regulator_set_enable(priv->vbus_supply, false);
-               if (ret) {
-                       dev_err(dev, "Error disabling vbus supply\n");
-                       return ret;
-               }
+       ret = regulator_set_enable_if_allowed(priv->vbus_supply, false);
+       if (ret && ret != -ENOSYS) {
+               dev_err(dev, "Error disabling vbus supply\n");
+               return ret;
        }
 
        return 0;