From aaad108b889c6980a2d05262a2f7febb14f94d68 Mon Sep 17 00:00:00 2001 From: "Kim B. Heino" Date: Fri, 12 Mar 2010 15:46:56 +0200 Subject: USB storage count Here's another USB storage patch. Currently U-Boot handles storage devices #0 - #4 as valid devices, even if there is none connected. This patch fixes usb_stor_get_dev() to check detected device count instead of MAX-define. This is very important for ill behaving devices. usb_dev_desc[] can be partially initialized if device probe fails. After fixing get_dev() it was easy to fix "usb part" etc commands. Previously it outputed "Unknown partition table" five times, now it's "no USB devices available". Signed-off-by: Kim B. Heino --- common/usb_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/usb_storage.c') diff --git a/common/usb_storage.c b/common/usb_storage.c index a8642c9cc5..239bddc511 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -175,7 +175,7 @@ void uhci_show_temp_int_td(void); block_dev_desc_t *usb_stor_get_dev(int index) { - return (index < USB_MAX_STOR_DEV) ? &usb_dev_desc[index] : NULL; + return (index < usb_max_devs) ? &usb_dev_desc[index] : NULL; } -- cgit v1.2.1 From fac71cc49f93db7d460dbc957dfbbadefa2ca0e9 Mon Sep 17 00:00:00 2001 From: "Kim B. Heino" Date: Fri, 12 Mar 2010 10:07:00 +0200 Subject: USB storage probe While debugging one ill behaving USB device I found two bugs in USB storage probe. usb_stor_get_info() returns -1 (error), 0 (skip) or 1 (ok). First part of this patch fixes error case. Second part fixes usb_inquiry()'s retry counter handling. Original code had retry = -1 on error case, not retry = 0 as checked in the next line. Signed-off-by: Kim B. Heino --- common/usb_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/usb_storage.c') diff --git a/common/usb_storage.c b/common/usb_storage.c index 239bddc511..4fc01a22b4 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -244,7 +244,7 @@ int usb_stor_scan(int mode) * get info and fill it in */ if (usb_stor_get_info(dev, &usb_stor[usb_max_devs], - &usb_dev_desc[usb_max_devs])) + &usb_dev_desc[usb_max_devs]) == 1) usb_max_devs++; } /* if storage device */ @@ -888,7 +888,7 @@ static int usb_inquiry(ccb *srb, struct us_data *ss) USB_STOR_PRINTF("inquiry returns %d\n", i); if (i == 0) break; - } while (retry--); + } while (--retry); if (!retry) { printf("error in inquiry\n"); -- cgit v1.2.1