From 3da0291ba9b4a429ed9226569c9014f5c7e13ac3 Mon Sep 17 00:00:00 2001 From: Hayes Wang Date: Fri, 22 May 2020 16:54:10 +0800 Subject: [PATCH 1/3] eth/r8152: fix assigning the wrong endpoint Although I think it never occurs, the code doesn't make sense, because it may allow to assign an IN endpoint to ss->ep_out. Signed-off-by: Hayes Wang --- drivers/usb/eth/r8152.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c index d9908ecc15..f201a1789b 100644 --- a/drivers/usb/eth/r8152.c +++ b/drivers/usb/eth/r8152.c @@ -1354,9 +1354,8 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum, struct usb_interface *iface; struct usb_interface_descriptor *iface_desc; int ep_in_found = 0, ep_out_found = 0; - int i; - struct r8152 *tp; + int i; /* let's examine the device now */ iface = &dev->config.if_desc[ifnum]; @@ -1399,10 +1398,13 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum, if ((iface->ep_desc[i].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { u8 ep_addr = iface->ep_desc[i].bEndpointAddress; - if ((ep_addr & USB_DIR_IN) && !ep_in_found) { - ss->ep_in = ep_addr & - USB_ENDPOINT_NUMBER_MASK; - ep_in_found = 1; + + if (ep_addr & USB_DIR_IN) { + if (!ep_in_found) { + ss->ep_in = ep_addr & + USB_ENDPOINT_NUMBER_MASK; + ep_in_found = 1; + } } else { if (!ep_out_found) { ss->ep_out = ep_addr & From 10bcafb8ace549e7e93afa335212a8e9072c5d0c Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 21 May 2020 23:32:23 +0200 Subject: [PATCH 2/3] usb: ehci-mx6: Handle fixed regulators correctly The regulator-fixed would return -ENOSYS when enabled/disabled, because this operation is not supported, but this is not an error e.g. on systems where the VBUS cannot be controlled, so if this is the error code reported by the regulator core, consider it a success and continue. Signed-off-by: Marek Vasut --- drivers/usb/host/ehci-mx6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 24f8ad7af8..470eddd0c9 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -447,7 +447,7 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) ret = regulator_set_enable(priv->vbus_supply, (type == USB_INIT_DEVICE) ? false : true); - if (ret) { + if (ret && ret != -ENOSYS) { puts("Error enabling VBUS supply\n"); return ret; } @@ -614,7 +614,7 @@ static int ehci_usb_probe(struct udevice *dev) ret = regulator_set_enable(priv->vbus_supply, (type == USB_INIT_DEVICE) ? false : true); - if (ret) { + if (ret && ret != -ENOSYS) { puts("Error enabling VBUS supply\n"); return ret; } From 73021d11d4d53cddaa2b1c8e0bd6eb3c79dc7fdc Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 21 May 2020 23:34:06 +0200 Subject: [PATCH 3/3] usb: ehci-mx6: Print error code on failure Print the error code if the regulator enable fails, otherwise the error message is rather useless and confusing. Signed-off-by: Marek Vasut --- drivers/usb/host/ehci-mx6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 470eddd0c9..5f84c7b91d 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -448,7 +448,7 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) (type == USB_INIT_DEVICE) ? false : true); if (ret && ret != -ENOSYS) { - puts("Error enabling VBUS supply\n"); + printf("Error enabling VBUS supply (ret=%i)\n", ret); return ret; } } @@ -615,7 +615,7 @@ static int ehci_usb_probe(struct udevice *dev) (type == USB_INIT_DEVICE) ? false : true); if (ret && ret != -ENOSYS) { - puts("Error enabling VBUS supply\n"); + printf("Error enabling VBUS supply (ret=%i)\n", ret); return ret; } }