- Free interrupt handler in ep_free().

- Move ep_pccard_detach() to if_ep.c and rename to ep_detach()
- Specify detach methods for all bus frontends.
This commit is contained in:
mdodd 2003-03-29 22:27:41 +00:00
parent fd8a9befab
commit ca79ae951e
6 changed files with 32 additions and 18 deletions

View File

@ -263,6 +263,8 @@ ep_free(device_t dev)
{
struct ep_softc * sc = device_get_softc(dev);
if (sc->ep_intrhand)
bus_teardown_intr(dev, sc->irq, sc->ep_intrhand);
if (sc->iobase)
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->iobase);
if (sc->irq)
@ -351,6 +353,31 @@ ep_attach(sc)
return 0;
}
int
ep_detach(device_t dev)
{
struct ep_softc *sc;
struct ifnet *ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
if (sc->gone) {
device_printf(dev, "already unloaded\n");
return (0);
}
epstop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
sc->gone = 1;
ep_free(dev);
return (0);
}
/*
* The order in here seems important. Otherwise we may not receive
* interrupts. ?!

View File

@ -250,6 +250,7 @@ static device_method_t ep_eisa_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ep_eisa_probe),
DEVMETHOD(device_attach, ep_eisa_attach),
DEVMETHOD(device_detach, ep_detach),
{ 0, 0 }
};

View File

@ -405,6 +405,7 @@ static device_method_t ep_isa_methods[] = {
#endif
DEVMETHOD(device_probe, ep_isa_probe),
DEVMETHOD(device_attach, ep_isa_attach),
DEVMETHOD(device_detach, ep_detach),
{ 0, 0 }
};

View File

@ -149,6 +149,7 @@ static device_method_t ep_mca_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ep_mca_probe),
DEVMETHOD(device_attach, ep_mca_attach),
DEVMETHOD(device_detach, ep_detach),
{ 0, 0 }
};

View File

@ -236,23 +236,6 @@ ep_pccard_attach(device_t dev)
return (error);
}
static int
ep_pccard_detach(device_t dev)
{
struct ep_softc *sc = device_get_softc(dev);
if (sc->gone) {
device_printf(dev, "already unloaded\n");
return (0);
}
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
ether_ifdetach(&sc->arpcom.ac_if);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq, sc->ep_intrhand);
ep_free(dev);
return (0);
}
static const struct pccard_product ep_pccard_products[] = {
PCMCIA_CARD(3COM, 3C1, 0),
PCMCIA_CARD(3COM, 3C562, 0),
@ -281,7 +264,7 @@ static device_method_t ep_pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_compat_probe),
DEVMETHOD(device_attach, pccard_compat_attach),
DEVMETHOD(device_detach, ep_pccard_detach),
DEVMETHOD(device_detach, ep_detach),
/* Card interface */
DEVMETHOD(card_compat_match, ep_pccard_match),

View File

@ -76,6 +76,7 @@ struct ep_softc {
int ep_alloc (device_t);
void ep_free (device_t);
int ep_detach (device_t);
void ep_get_media (struct ep_softc *);
int ep_attach (struct ep_softc *);
void ep_intr (void *);