
regulator_set_enable_if_allowed already handles cases when the regulator is already enabled, or already disabled, and does not treat these as errors. With this change, the driver can work correctly even if the regulator is already taken or already disabled by another consumer.
Signed-off-by: Eugen Hristev eugen.hristev@collabora.com --- Hi Tim,
I have not tested this as I do not have a mx6 board. can you please try it ?
Thanks, Eugen
drivers/usb/host/ehci-mx6.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 91633f013a55..7806a4de71e0 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -480,9 +480,9 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) { int ret; - ret = regulator_set_enable(priv->vbus_supply, - (type == USB_INIT_DEVICE) ? - false : true); + ret = regulator_set_enable_if_allowed(priv->vbus_supply, + (type == USB_INIT_DEVICE) ? + false : true); if (ret && ret != -ENOSYS) { printf("Error enabling VBUS supply (ret=%i)\n", ret); return ret; @@ -707,9 +707,9 @@ static int ehci_usb_probe(struct udevice *dev)
#if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, - (type == USB_INIT_DEVICE) ? - false : true); + ret = regulator_set_enable_if_allowed(priv->vbus_supply, + (type == USB_INIT_DEVICE) ? + false : true); if (ret && ret != -ENOSYS) { printf("Error enabling VBUS supply (ret=%i)\n", ret); goto err_clk; @@ -748,7 +748,7 @@ err_regulator: #endif #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) - regulator_set_enable(priv->vbus_supply, false); + regulator_set_enable_if_allowed(priv->vbus_supply, false); #endif err_clk: #if CONFIG_IS_ENABLED(CLK) @@ -772,7 +772,7 @@ int ehci_usb_remove(struct udevice *dev)
#if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) - regulator_set_enable(priv->vbus_supply, false); + regulator_set_enable_if_allowed(priv->vbus_supply, false); #endif
#if CONFIG_IS_ENABLED(CLK)