diff mbox

[U-Boot,v2,2/3] usb: Check usb_new_device for failure

Message ID 1427624899-9537-2-git-send-email-contact@paulk.fr
State Superseded
Delegated to: Marek Vasut
Headers show

Commit Message

Paul Kocialkowski March 29, 2015, 10:28 a.m. UTC
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 common/usb.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Marek Vasut April 3, 2015, 2:03 a.m. UTC | #1
On Sunday, March 29, 2015 at 12:28:18 PM, Paul Kocialkowski wrote:
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

I don't really want to spell it out, but I guess I have to, sorry ...

Commit message please.

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/common/usb.c b/common/usb.c
index ea5b406..67e2350 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -95,18 +95,24 @@  int usb_init(void)
 		start_index = dev_index;
 		printf("scanning bus %d for devices... ", i);
 		dev = usb_alloc_new_device(ctrl);
+		if (!dev)
+			break;
+
 		/*
 		 * device 0 is always present
 		 * (root hub, so let it analyze)
 		 */
-		if (dev)
-			usb_new_device(dev);
+		ret = usb_new_device(dev);
+		if (ret)
+			usb_free_device();
 
-		if (start_index == dev_index)
+		if (start_index == dev_index) {
 			puts("No USB Device found\n");
-		else
+			continue;
+		} else {
 			printf("%d USB Device(s) found\n",
 				dev_index - start_index);
+		}
 
 		usb_started = 1;
 	}