diff options
author | imp <imp@FreeBSD.org> | 2005-02-08 05:45:35 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2005-02-08 05:45:35 +0000 |
commit | 7bb35cb182703c30113f937e43890f82e0da8cf8 (patch) | |
tree | 37cc39199a86704ae89359f1c5fc272b93ca8187 /sys | |
parent | 28c345cd334c83405a093b56c6c6ac25d924370e (diff) | |
download | FreeBSD-src-7bb35cb182703c30113f937e43890f82e0da8cf8.zip FreeBSD-src-7bb35cb182703c30113f937e43890f82e0da8cf8.tar.gz |
Make it possible to unload ed. Move the ed_pccard_detach routine to
if_ed and rename it to ed_detach(). Tell other busses to use this
routine for detach.
Since I don't actually have any non-pccard ed hardware I can test
with, I've only tested with my pccards.
More improvements in this area likely are possible.
Prodded by: rwatson
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ed/if_ed.c | 20 | ||||
-rw-r--r-- | sys/dev/ed/if_ed_cbus.c | 1 | ||||
-rw-r--r-- | sys/dev/ed/if_ed_isa.c | 1 | ||||
-rw-r--r-- | sys/dev/ed/if_ed_pccard.c | 23 | ||||
-rw-r--r-- | sys/dev/ed/if_ed_pci.c | 1 | ||||
-rw-r--r-- | sys/dev/ed/if_edvar.h | 1 |
6 files changed, 25 insertions, 22 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 1329753..10385f4 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -1779,6 +1779,26 @@ ed_attach(dev) } /* + * Detach the driver from the hardware and other systems in the kernel. + */ +int +ed_detach(device_t dev) +{ + struct ed_softc *sc = device_get_softc(dev); + struct ifnet *ifp = &sc->arpcom.ac_if; + + if (sc->gone) + return (0); + ed_stop(sc); + ifp->if_flags &= ~IFF_RUNNING; + ether_ifdetach(ifp); + sc->gone = 1; + bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); + ed_release_resources(dev); + return (0); +} + +/* * Reset interface. */ static void diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c index 1f84243..328c50e 100644 --- a/sys/dev/ed/if_ed_cbus.c +++ b/sys/dev/ed/if_ed_cbus.c @@ -1743,6 +1743,7 @@ static device_method_t ed_isa_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ed_isa_probe), DEVMETHOD(device_attach, ed_isa_attach), + DEVMETHOD(device_attach, ed_detach), { 0, 0 } }; diff --git a/sys/dev/ed/if_ed_isa.c b/sys/dev/ed/if_ed_isa.c index 3a5804c..bf2c40f 100644 --- a/sys/dev/ed/if_ed_isa.c +++ b/sys/dev/ed/if_ed_isa.c @@ -148,6 +148,7 @@ static device_method_t ed_isa_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ed_isa_probe), DEVMETHOD(device_attach, ed_isa_attach), + DEVMETHOD(device_detach, ed_detach), { 0, 0 } }; diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c index b1994c3..ad548e2 100644 --- a/sys/dev/ed/if_ed_pccard.c +++ b/sys/dev/ed/if_ed_pccard.c @@ -75,7 +75,6 @@ MODULE_DEPEND(ed, ether, 1, 1, 1); static int ed_pccard_match(device_t); static int ed_pccard_probe(device_t); static int ed_pccard_attach(device_t); -static int ed_pccard_detach(device_t); static int ed_pccard_ax88190(device_t dev); @@ -89,26 +88,6 @@ static void ed_pccard_dlink_mii_writebits(struct ed_softc *sc, u_int val, #endif static int ed_pccard_Linksys(device_t dev); -/* - * ed_pccard_detach - unload the driver and clear the table. - */ -static int -ed_pccard_detach(device_t dev) -{ - struct ed_softc *sc = device_get_softc(dev); - struct ifnet *ifp = &sc->arpcom.ac_if; - - if (sc->gone) - return (0); - ed_stop(sc); - ifp->if_flags &= ~IFF_RUNNING; - ether_ifdetach(ifp); - sc->gone = 1; - bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); - ed_release_resources(dev); - return (0); -} - static const struct ed_product { struct pccard_product prod; int flags; @@ -508,7 +487,7 @@ static device_method_t ed_pccard_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pccard_compat_probe), DEVMETHOD(device_attach, pccard_compat_attach), - DEVMETHOD(device_detach, ed_pccard_detach), + DEVMETHOD(device_detach, ed_detach), #ifndef ED_NO_MIIBUS /* Bus interface */ diff --git a/sys/dev/ed/if_ed_pci.c b/sys/dev/ed/if_ed_pci.c index e8d12b8..71fe499 100644 --- a/sys/dev/ed/if_ed_pci.c +++ b/sys/dev/ed/if_ed_pci.c @@ -109,6 +109,7 @@ static device_method_t ed_pci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ed_pci_probe), DEVMETHOD(device_attach, ed_pci_attach), + DEVMETHOD(device_attach, ed_detach), { 0, 0 } }; diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h index 2bbec48..ff693f4 100644 --- a/sys/dev/ed/if_edvar.h +++ b/sys/dev/ed/if_edvar.h @@ -205,6 +205,7 @@ int ed_probe_Novell_generic(device_t, int); int ed_probe_HP_pclanp(device_t, int, int); int ed_attach(device_t); +int ed_detach(device_t); void ed_stop(struct ed_softc *); void ed_pio_readmem(struct ed_softc *, long, unsigned char *, unsigned short); void ed_pio_writemem(struct ed_softc *, char *, unsigned short, unsigned short); |