diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2015-04-04 15:12:28 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2015-04-14 05:47:48 +0200 |
commit | 8879be88576024a48ae135ea0b3835727d8c9a3a (patch) | |
tree | 67035fccdae5082272c58e4a4a26d1e359344445 | |
parent | 5a80b3449ba7a3ef0230a79b8e26252b885f7616 (diff) | |
download | u-boot-imx-8879be88576024a48ae135ea0b3835727d8c9a3a.zip u-boot-imx-8879be88576024a48ae135ea0b3835727d8c9a3a.tar.gz u-boot-imx-8879be88576024a48ae135ea0b3835727d8c9a3a.tar.bz2 |
usb: Check usb_new_device for failure
This checks that a new USB device is correctly initialized and frees it if not.
In addition, this doesn't report that USB was started when no device was found.
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | common/usb.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/common/usb.c b/common/usb.c index 1288ca0..6ed3124 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; } |