Please disregard the previous patch sent. It has an embarassing bug
within it (as you probably have seen). This is the fixed version. Please
accept it if it is suitable.
--- linux-2.4.17stock/drivers/usb/usb-ohci.c Fri Dec 21 11:41:55 2001
+++ linux/drivers/usb/usb-ohci.c Tue Jan 22 11:18:46 2002
@@ -12,6 +12,8 @@
*
* History:
*
+ * 2002/01/18 Fixes to make driver cleanup after itself if it doesn't
+ * load properly
* 2001/09/19 USB_ZERO_PACKET support (Jean Tourrilhes)
* 2001/07/17 power management and pmac cleanup (Benjamin Herrenschmidt)
* 2001/03/24 td/ed hashing to remove bus_to_virt (Steve Longerbeam);
@@ -47,6 +49,7 @@
* v1.0 1999/04/27 initial release
*/
+
#include <linux/config.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -2381,6 +2384,8 @@
bus = usb_alloc_bus (&sohci_device_operations);
if (!bus) {
+ pci_set_drvdata(dev, NULL);
+ pci_free_consistent(ohci->ohci_dev, sizeof *ohci->hcca, ohci->hcca,
+ohci->hcca_dma);
kfree (ohci);
return NULL;
}
@@ -2413,8 +2418,11 @@
}
pci_set_drvdata(ohci->ohci_dev, NULL);
- usb_deregister_bus (ohci->bus);
- usb_free_bus (ohci->bus);
+ if (ohci->bus) {
+ if (ohci->bus->busnum)
+ usb_deregister_bus (ohci->bus);
+ usb_free_bus (ohci->bus);
+ }
list_del (&ohci->ohci_hcd_list);
INIT_LIST_HEAD (&ohci->ohci_hcd_list);
@@ -2560,6 +2568,7 @@
static int __devinit
ohci_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
{
+ int res = 0;
unsigned long mem_resource, mem_len;
void *mem_base;
@@ -2568,6 +2577,7 @@
if (!dev->irq) {
err("found OHCI device with no IRQ assigned. check BIOS settings!");
+ pci_disable_device(dev);
return -ENODEV;
}
@@ -2576,19 +2586,31 @@
mem_len = pci_resource_len(dev, 0);
if (!request_mem_region (mem_resource, mem_len, ohci_pci_driver.name)) {
dbg ("controller already in use");
+ pci_disable_device(dev);
return -EBUSY;
}
mem_base = ioremap_nocache (mem_resource, mem_len);
if (!mem_base) {
err("Error mapping OHCI memory");
+ release_mem_region(mem_resource, mem_len);
+ pci_disable_device(dev);
return -EFAULT;
}
/* controller writes into our memory */
pci_set_master (dev);
- return hc_found_ohci (dev, dev->irq, mem_base, id);
+ res = hc_found_ohci (dev, dev->irq, mem_base, id);
+ if (res < 0) {
+ iounmap(mem_base);
+ release_mem_region(mem_resource, mem_len);
+ pci_disable_device(dev);
+ }
+
+ return res;
+
+
}
/*-------------------------------------------------------------------------*/
Thanks,
Matthew Fredrickson
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel