diff options
author | iedowse <iedowse@FreeBSD.org> | 2004-08-02 15:37:35 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2004-08-02 15:37:35 +0000 |
commit | 4d8c7e278116822a79a8e6f3289597805631b781 (patch) | |
tree | f9651ebefb22b158edbbdb2ae4fbc1c3857d340a /sys/dev/usb/ohci_pci.c | |
parent | fb7f90d7ec95dc92cb81c6e9b8768b90f31666ad (diff) | |
download | FreeBSD-src-4d8c7e278116822a79a8e6f3289597805631b781.zip FreeBSD-src-4d8c7e278116822a79a8e6f3289597805631b781.tar.gz |
Make the USB subsystem unloadable and detachable, though currently
a significant amount of memory may be leaked each time a host
controller is detached.
Diffstat (limited to 'sys/dev/usb/ohci_pci.c')
-rw-r--r-- | sys/dev/usb/ohci_pci.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/sys/dev/usb/ohci_pci.c b/sys/dev/usb/ohci_pci.c index 0aa9f5d..6700323 100644 --- a/sys/dev/usb/ohci_pci.c +++ b/sys/dev/usb/ohci_pci.c @@ -290,8 +290,10 @@ ohci_pci_attach(device_t self) return ENXIO; } err = ohci_init(sc); - if (!err) + if (!err) { + sc->sc_flags |= OHCI_SCFLG_DONEINIT; err = device_probe_and_attach(sc->sc_bus.bdev); + } if (err) { device_printf(self, "USB init failed\n"); @@ -306,17 +308,10 @@ ohci_pci_detach(device_t self) { ohci_softc_t *sc = device_get_softc(self); - /* - * XXX this code is not yet fit to be used as detach for the OHCI - * controller - */ - - /* - * disable interrupts that might have been switched on in ohci_init - */ - if (sc->iot && sc->ioh) - bus_space_write_4(sc->iot, sc->ioh, - OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); + if (sc->sc_flags & OHCI_SCFLG_DONEINIT) { + ohci_detach(sc, 0); + sc->sc_flags &= ~OHCI_SCFLG_DONEINIT; + } if (sc->irq_res && sc->ih) { int err = bus_teardown_intr(self, sc->irq_res, sc->ih); @@ -348,6 +343,7 @@ static device_method_t ohci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ohci_pci_probe), DEVMETHOD(device_attach, ohci_pci_attach), + DEVMETHOD(device_detach, ohci_pci_detach), DEVMETHOD(device_suspend, ohci_pci_suspend), DEVMETHOD(device_resume, ohci_pci_resume), DEVMETHOD(device_shutdown, bus_generic_shutdown), |