Greg:
This patch changes the device initialization code for the UHCI driver to
use a more meaningful timeout than simply waiting for 1000 loop
iterations. It also causes the code to fail when a timeout occurs rather
than proceed blindly.
Please apply.
Alan Stern
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
===== drivers/usb/host/uhci-hcd.c 1.139 vs edited =====
--- 1.139/drivers/usb/host/uhci-hcd.c 2004-10-21 16:02:20 -04:00
+++ edited/drivers/usb/host/uhci-hcd.c 2004-10-29 15:40:42 -04:00
@@ -1852,10 +1852,10 @@
}
}
-static void start_hc(struct uhci_hcd *uhci)
+static int start_hc(struct uhci_hcd *uhci)
{
unsigned long io_addr = uhci->io_addr;
- int timeout = 1000;
+ int timeout = 10;
/*
* Reset the HC - this will force us to get a
@@ -1865,10 +1865,11 @@
*/
outw(USBCMD_HCRESET, io_addr + USBCMD);
while (inw(io_addr + USBCMD) & USBCMD_HCRESET) {
- if (!--timeout) {
+ if (--timeout < 0) {
dev_err(uhci_dev(uhci), "USBCMD_HCRESET timed out!\n");
- break;
+ return -ETIMEDOUT;
}
+ msleep(1);
}
/* Turn on PIRQ and all interrupts */
@@ -1887,6 +1888,7 @@
outw(USBCMD_RS | USBCMD_CF | USBCMD_MAXP, io_addr + USBCMD);
uhci->hcd.state = USB_STATE_RUNNING;
+ return 0;
}
/*
@@ -2138,7 +2140,8 @@
* the memory writes above before the I/O transfers in start_hc().
*/
mb();
- start_hc(uhci);
+ if ((retval = start_hc(uhci)) != 0)
+ goto err_alloc_skelqh;
init_stall_timer(hcd);
@@ -2244,6 +2247,7 @@
static int uhci_resume(struct usb_hcd *hcd)
{
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
+ int rc;
pci_set_master(to_pci_dev(uhci_dev(uhci)));
@@ -2266,7 +2270,8 @@
USBLEGSUP_DEFAULT);
} else {
reset_hc(uhci);
- start_hc(uhci);
+ if ((rc = start_hc(uhci)) != 0)
+ return rc;
}
uhci->hcd.state = USB_STATE_RUNNING;
return 0;
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel