diff options
author | Simon Glass <sjg@chromium.org> | 2015-03-25 12:22:13 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-04-18 11:11:22 -0600 |
commit | 84073b6f3c202f5d67813fd3ae5377bf2d98d66b (patch) | |
tree | 038dd7f855069120e83ee60978eea60a26e0b86c /common/usb_storage.c | |
parent | 1d5827a12ebd20d64b972111b846cb1ca87ff82e (diff) |
dm: usb: Simply device finding code in usb_storage
The for() loop is not needed since the value is immediately accessible.
Use this instead to simplify the code.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'common/usb_storage.c')
-rw-r--r-- | common/usb_storage.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/common/usb_storage.c b/common/usb_storage.c index 5108d23434..2955b325b8 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -1018,7 +1018,7 @@ unsigned long usb_stor_read(int device, lbaint_t blknr, unsigned short smallblks; struct usb_device *dev; struct us_data *ss; - int retry, i; + int retry; ccb *srb = &usb_ccb; if (blkcnt == 0) @@ -1026,14 +1026,11 @@ unsigned long usb_stor_read(int device, lbaint_t blknr, device &= 0xff; /* Setup device */ - debug("\nusb_read: dev %d \n", device); - dev = NULL; - for (i = 0; i < USB_MAX_DEVICE; i++) { - dev = usb_get_dev_index(i); - if (dev == NULL) - return 0; - if (dev->devnum == usb_dev_desc[device].target) - break; + debug("\nusb_read: dev %d\n", device); + dev = usb_dev_desc[device].priv; + if (!dev) { + debug("%s: No device\n", __func__); + return 0; } ss = (struct us_data *)dev->privptr; @@ -1091,7 +1088,7 @@ unsigned long usb_stor_write(int device, lbaint_t blknr, unsigned short smallblks; struct usb_device *dev; struct us_data *ss; - int retry, i; + int retry; ccb *srb = &usb_ccb; if (blkcnt == 0) @@ -1099,15 +1096,10 @@ unsigned long usb_stor_write(int device, lbaint_t blknr, device &= 0xff; /* Setup device */ - debug("\nusb_write: dev %d \n", device); - dev = NULL; - for (i = 0; i < USB_MAX_DEVICE; i++) { - dev = usb_get_dev_index(i); - if (dev == NULL) - return 0; - if (dev->devnum == usb_dev_desc[device].target) - break; - } + debug("\nusb_write: dev %d\n", device); + dev = usb_dev_desc[device].priv; + if (!dev) + return 0; ss = (struct us_data *)dev->privptr; usb_disable_asynch(1); /* asynch transfer not allowed */ |