Skip to content
Snippets Groups Projects
Commit 84073b6f authored by Simon Glass's avatar Simon Glass
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarMarek Vasut <marex@denx.de>
parent 1d5827a1
No related branches found
No related tags found
No related merge requests found
...@@ -1018,7 +1018,7 @@ unsigned long usb_stor_read(int device, lbaint_t blknr, ...@@ -1018,7 +1018,7 @@ unsigned long usb_stor_read(int device, lbaint_t blknr,
unsigned short smallblks; unsigned short smallblks;
struct usb_device *dev; struct usb_device *dev;
struct us_data *ss; struct us_data *ss;
int retry, i; int retry;
ccb *srb = &usb_ccb; ccb *srb = &usb_ccb;
if (blkcnt == 0) if (blkcnt == 0)
...@@ -1026,14 +1026,11 @@ unsigned long usb_stor_read(int device, lbaint_t blknr, ...@@ -1026,14 +1026,11 @@ unsigned long usb_stor_read(int device, lbaint_t blknr,
device &= 0xff; device &= 0xff;
/* Setup device */ /* Setup device */
debug("\nusb_read: dev %d \n", device); debug("\nusb_read: dev %d\n", device);
dev = NULL; dev = usb_dev_desc[device].priv;
for (i = 0; i < USB_MAX_DEVICE; i++) { if (!dev) {
dev = usb_get_dev_index(i); debug("%s: No device\n", __func__);
if (dev == NULL) return 0;
return 0;
if (dev->devnum == usb_dev_desc[device].target)
break;
} }
ss = (struct us_data *)dev->privptr; ss = (struct us_data *)dev->privptr;
...@@ -1091,7 +1088,7 @@ unsigned long usb_stor_write(int device, lbaint_t blknr, ...@@ -1091,7 +1088,7 @@ unsigned long usb_stor_write(int device, lbaint_t blknr,
unsigned short smallblks; unsigned short smallblks;
struct usb_device *dev; struct usb_device *dev;
struct us_data *ss; struct us_data *ss;
int retry, i; int retry;
ccb *srb = &usb_ccb; ccb *srb = &usb_ccb;
if (blkcnt == 0) if (blkcnt == 0)
...@@ -1099,15 +1096,10 @@ unsigned long usb_stor_write(int device, lbaint_t blknr, ...@@ -1099,15 +1096,10 @@ unsigned long usb_stor_write(int device, lbaint_t blknr,
device &= 0xff; device &= 0xff;
/* Setup device */ /* Setup device */
debug("\nusb_write: dev %d \n", device); debug("\nusb_write: dev %d\n", device);
dev = NULL; dev = usb_dev_desc[device].priv;
for (i = 0; i < USB_MAX_DEVICE; i++) { if (!dev)
dev = usb_get_dev_index(i); return 0;
if (dev == NULL)
return 0;
if (dev->devnum == usb_dev_desc[device].target)
break;
}
ss = (struct us_data *)dev->privptr; ss = (struct us_data *)dev->privptr;
usb_disable_asynch(1); /* asynch transfer not allowed */ usb_disable_asynch(1); /* asynch transfer not allowed */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment