diff mbox series

[v3,2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed()

Message ID 20231009131536.3475878-2-festevam@gmail.com
State Accepted
Commit 7478c84f3d9f84b4fa748dae222d78c9a12e25f7
Delegated to: Stefano Babic
Headers show
Series [v3,1/3] usb: ehci: mxs: Fix the USB node pointer retrieval | expand

Commit Message

Fabio Estevam Oct. 9, 2023, 1:15 p.m. UTC
From: Fabio Estevam <festevam@denx.de>

Since commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable() may be EALREADY or
EBUSY for fixed/GPIO regulators.

Switch to using the more relaxed regulator_set_enable_if_allowed() to
continue if regulator already was enabled or disabled.

This fixes the following error when running the 'ums' command:

=> ums 0 mmc 0
UMS: LUN 0, dev mmc 0, hwpart 0, sector 0x0, count 0xece000
Error enabling VBUS supply
g_dnl_register: failed!, error: -114
g_dnl_register failed

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
---
Changes since v2:
- None
Changes since v1:
- Only collected Marek's Reviewed-by tag.

 drivers/usb/host/ehci-mxs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefano Babic Oct. 16, 2023, 9:23 a.m. UTC | #1
> From: Fabio Estevam <festevam@denx.de>
> Since commit 4fcba5d556b4 ("regulator: implement basic reference
> counter") the return value of regulator_set_enable() may be EALREADY or
> EBUSY for fixed/GPIO regulators.
> Switch to using the more relaxed regulator_set_enable_if_allowed() to
> continue if regulator already was enabled or disabled.
> This fixes the following error when running the 'ums' command:
> => ums 0 mmc 0
> UMS: LUN 0, dev mmc 0, hwpart 0, sector 0x0, count 0xece000
> Error enabling VBUS supply
> g_dnl_register: failed!, error: -114
> g_dnl_register failed
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-mxs.c b/drivers/usb/host/ehci-mxs.c
index 092c79fd4bc5..ddf7cc2d00a7 100644
--- a/drivers/usb/host/ehci-mxs.c
+++ b/drivers/usb/host/ehci-mxs.c
@@ -236,9 +236,9 @@  static int ehci_usb_probe(struct udevice *dev)
 		debug("%s: No vbus supply\n", dev->name);
 
 	if (!ret && 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) {
 			puts("Error enabling VBUS supply\n");
 			return ret;
@@ -265,7 +265,7 @@  static int ehci_usb_remove(struct udevice *dev)
 
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	if (priv->vbus_supply) {
-		ret = regulator_set_enable(priv->vbus_supply, false);
+		ret = regulator_set_enable_if_allowed(priv->vbus_supply, false);
 		if (ret) {
 			puts("Error disabling VBUS supply\n");
 			return ret;