usb: onboard-hub: Fix return type for regulator APIs
authorPadmarao Begari <padmarao.begari@amd.com>
Fri, 11 Apr 2025 05:55:38 +0000 (07:55 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 4 Jun 2025 08:24:16 +0000 (10:24 +0200)
Apart from ENOENT observing return value as ENOSYS when
!DM_REGULATOR that's why cover both configurations.
Changed code is not working as operation should be "&&"
not "||" (ret != -ENOENT && ret != -ENOSYS).

Also fix the remove function where the regulator_set_enable_if_allowed()
function is returning an error.

Signed-off-by: Padmarao Begari <padmarao.begari@amd.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/a2d520f14efc30fc28ec59881205e156dabbfcd9.1744350937.git.michal.simek@amd.com
common/usb_onboard_hub.c

index 7fe62b0..d17c85d 100644 (file)
@@ -146,7 +146,7 @@ static int usb_onboard_hub_probe(struct udevice *dev)
        int ret;
 
        ret = device_get_supply_regulator(dev, "vdd-supply", &hub->vdd);
-       if (ret && ret != -ENOENT) {
+       if (ret && ret != -ENOENT && ret != -ENOSYS) {
                dev_err(dev, "can't get vdd-supply: %d\n", ret);
                return ret;
        }
@@ -204,14 +204,16 @@ static int usb_onboard_hub_bind(struct udevice *dev)
 static int usb_onboard_hub_remove(struct udevice *dev)
 {
        struct onboard_hub *hub = dev_get_priv(dev);
-       int ret;
+       int ret = 0;
 
        if (hub->reset_gpio)
                dm_gpio_free(hub->reset_gpio->dev, hub->reset_gpio);
 
-       ret = regulator_set_enable_if_allowed(hub->vdd, false);
-       if (ret)
-               dev_err(dev, "can't disable vdd-supply: %d\n", ret);
+       if (hub->vdd) {
+               ret = regulator_set_enable_if_allowed(hub->vdd, false);
+               if (ret)
+                       dev_err(dev, "can't disable vdd-supply: %d\n", ret);
+       }
 
        return ret;
 }