]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
USB storage probe
authorKim B. Heino <Kim.Heino@bluegiga.com>
Fri, 12 Mar 2010 08:07:00 +0000 (10:07 +0200)
committerRemy Bohmer <linux@bohmer.net>
Thu, 8 Apr 2010 19:40:00 +0000 (21:40 +0200)
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 <Kim.Heino@bluegiga.com>
common/usb_storage.c

index 239bddc5118d5238f9e8205123742ab2a127ee84..4fc01a22b4d4e5c95adfb81c8274baf2016f638b 100644 (file)
@@ -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");