diff options
-rw-r--r-- | src/lib/usbdebug.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c index a9a7e17597..4a1228f158 100644 --- a/src/lib/usbdebug.c +++ b/src/lib/usbdebug.c @@ -540,24 +540,28 @@ try_next_port: dbgp_mdelay(100); /* Find the debug device and make it device number 127 */ - for (devnum = 0; devnum <= 127; devnum++) { - ret = dbgp_control_msg(ehci_debug, devnum, - USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE, - USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0, - &dbgp_desc, sizeof(dbgp_desc)); - if (ret > 0) - break; + devnum = 0; +debug_dev_retry: + memset(&dbgp_desc, 0, sizeof(dbgp_desc)); + ret = dbgp_control_msg(ehci_debug, devnum, + USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE, + USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0, + &dbgp_desc, sizeof(dbgp_desc)); + if (ret == sizeof(dbgp_desc)) { + if (dbgp_desc.bLength == sizeof(dbgp_desc) && dbgp_desc.bDescriptorType==USB_DT_DEBUG) + goto debug_dev_found; + else + dprintk(BIOS_INFO, "Invalid debug device descriptor.\n"); } - if (devnum > 127) { + if (devnum == 0) { + devnum = USB_DEBUG_DEVNUM; + goto debug_dev_retry; + } else { dprintk(BIOS_INFO, "Could not find attached debug device.\n"); ret = -5; goto err; } - if (ret < 0) { - dprintk(BIOS_INFO, "Attached device is not a debug device.\n"); - ret = -6; - goto err; - } +debug_dev_found: /* Move the device to 127 if it isn't already there */ if (devnum != USB_DEBUG_DEVNUM) { |