summaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2005-05-31 22:33:21 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-27 23:44:00 +0200
commite07fefa6b212f43c40fdbc1a62de690d91a4b617 (patch)
tree8426cdb4a4b8c7b9a0ce2cc360beebf9499d9572 /drivers/usb/host
parent[PATCH] USB gadget: drain rndis response queue on disconnect (diff)
downloadlinux-e07fefa6b212f43c40fdbc1a62de690d91a4b617.tar.xz
linux-e07fefa6b212f43c40fdbc1a62de690d91a4b617.zip
[PATCH] USB UHCI: Detect invalid ports
This patch changes the way uhci-hcd detects valid ports. The specification doesn't mention any way to find out how many ports a controller has, so the driver has to use some heuristics, reading the port status and control register and deciding whether the value makes sense. With this patch the driver will recognize a typical failure mode (all bits set to one) for nonexistent ports and won't assume there are always at least 2 ports -- such an assumption seems silly if the heuristics have already shown that the ports don't exist. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/uhci-hcd.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index fdf54295da73..0d5d2545bf07 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -495,24 +495,24 @@ static int uhci_reset(struct usb_hcd *hcd)
/* The UHCI spec says devices must have 2 ports, and goes on to say
* they may have more but gives no way to determine how many there
- * are. However, according to the UHCI spec, Bit 7 of the port
+ * are. However according to the UHCI spec, Bit 7 of the port
* status and control register is always set to 1. So we try to
- * use this to our advantage.
+ * use this to our advantage. Another common failure mode when
+ * a nonexistent register is addressed is to return all ones, so
+ * we test for that also.
*/
for (port = 0; port < (io_size - USBPORTSC1) / 2; port++) {
unsigned int portstatus;
portstatus = inw(uhci->io_addr + USBPORTSC1 + (port * 2));
- if (!(portstatus & 0x0080))
+ if (!(portstatus & 0x0080) || portstatus == 0xffff)
break;
}
if (debug)
dev_info(uhci_dev(uhci), "detected %d ports\n", port);
- /* Anything less than 2 or greater than 7 is weird,
- * so we'll ignore it.
- */
- if (port < 2 || port > UHCI_RH_MAXCHILD) {
+ /* Anything greater than 7 is weird so we'll ignore it. */
+ if (port > UHCI_RH_MAXCHILD) {
dev_info(uhci_dev(uhci), "port count misdetected? "
"forcing to 2 ports\n");
port = 2;