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
This commit is contained in:
Warner Losh 2005-02-08 05:45:35 +00:00
parent 442b6e9e8c
commit 9d512034e3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141494
6 changed files with 25 additions and 22 deletions

View File

@ -1778,6 +1778,26 @@ ed_attach(dev)
return (0);
}
/*
* 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.
*/

View File

@ -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 }
};

View File

@ -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 }
};

View File

@ -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 */

View File

@ -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 }
};

View File

@ -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);