diff options
-rw-r--r-- | common/cmd_usb.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/usb-uclass.c | 10 |
2 files changed, 9 insertions, 10 deletions
diff --git a/common/cmd_usb.c b/common/cmd_usb.c index ca06826901f..2ed4cb474f8 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -630,12 +630,11 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) bus; uclass_next_device(&bus)) { struct usb_device *udev; - struct udevice *hub; + struct udevice *dev; - device_find_first_child(bus, &hub); - if (device_get_uclass_id(hub) == UCLASS_USB_HUB && - device_active(hub)) { - udev = dev_get_parentdata(hub); + device_find_first_child(bus, &dev); + if (dev && device_active(dev)) { + udev = dev_get_parentdata(dev); usb_show_tree(udev); } } diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index b0e6e71a8fb..c5d1e7feb9d 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -303,14 +303,14 @@ static struct usb_device *find_child_devnum(struct udevice *parent, int devnum) struct usb_device *usb_get_dev_index(struct udevice *bus, int index) { - struct udevice *hub; + struct udevice *dev; int devnum = index + 1; /* Addresses are allocated from 1 on USB */ - device_find_first_child(bus, &hub); - if (device_get_uclass_id(hub) == UCLASS_USB_HUB) - return find_child_devnum(hub, devnum); + device_find_first_child(bus, &dev); + if (!dev) + return NULL; - return NULL; + return find_child_devnum(dev, devnum); } int usb_post_bind(struct udevice *dev) |