summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-04-09 21:42:18 +0200
committerWolfgang Denk <wd@denx.de>2010-04-09 21:42:18 +0200
commit2aa4c57a101c0432e110561f5439560faf4e8018 (patch)
tree571815a2bbd914d1588b12140c8502022942af41 /common
parent760bce07f182f678d42f2a85a0e47b59e831ba25 (diff)
parentfac71cc49f93db7d460dbc957dfbbadefa2ca0e9 (diff)
downloadu-boot-imx-2aa4c57a101c0432e110561f5439560faf4e8018.zip
u-boot-imx-2aa4c57a101c0432e110561f5439560faf4e8018.tar.gz
u-boot-imx-2aa4c57a101c0432e110561f5439560faf4e8018.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-usb
Diffstat (limited to 'common')
-rw-r--r--common/cmd_usb.c13
-rw-r--r--common/usb_storage.c6
2 files changed, 11 insertions, 8 deletions
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 6b5c582..ee3755c 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -387,7 +387,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
dev = simple_strtoul(boot_device, &ep, 16);
stor_dev = usb_stor_get_dev(dev);
- if (stor_dev->type == DEV_TYPE_UNKNOWN) {
+ if (stor_dev == NULL || stor_dev->type == DEV_TYPE_UNKNOWN) {
printf("\n** Device %d not available\n", dev);
return 1;
}
@@ -595,8 +595,10 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (strncmp(argv[1], "part", 4) == 0) {
int devno, ok = 0;
if (argc == 2) {
- for (devno = 0; devno < USB_MAX_STOR_DEV; ++devno) {
+ for (devno = 0; ; ++devno) {
stor_dev = usb_stor_get_dev(devno);
+ if (stor_dev == NULL)
+ break;
if (stor_dev->type != DEV_TYPE_UNKNOWN) {
ok++;
if (devno)
@@ -608,7 +610,8 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
} else {
devno = simple_strtoul(argv[2], NULL, 16);
stor_dev = usb_stor_get_dev(devno);
- if (stor_dev->type != DEV_TYPE_UNKNOWN) {
+ if (stor_dev != NULL &&
+ stor_dev->type != DEV_TYPE_UNKNOWN) {
ok++;
debug("print_part of %x\n", devno);
print_part(stor_dev);
@@ -668,12 +671,12 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (argc == 3) {
int dev = (int)simple_strtoul(argv[2], NULL, 10);
printf("\nUSB device %d: ", dev);
- if (dev >= USB_MAX_STOR_DEV) {
+ stor_dev = usb_stor_get_dev(dev);
+ if (stor_dev == NULL) {
printf("unknown device\n");
return 1;
}
printf("\n Device %d: ", dev);
- stor_dev = usb_stor_get_dev(dev);
dev_print(stor_dev);
if (stor_dev->type == DEV_TYPE_UNKNOWN)
return 1;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index a8642c9..4fc01a2 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;
}
@@ -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");