From 20f0c80f6feb5e1ab73e06f9565732b34180dbad Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Fri, 11 Apr 2003 12:52:52 +0000 Subject: - Call ether_ifdetach() before shutting down the hardware. - Remove a useless device_is_alive() check. - Disable interrupts if bus_child_present() so that this check is more useful. This fixes the hangs I was seeing when unloading the fxp driver. Suggestions from: hsu, njl --- sys/dev/fxp/if_fxp.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 2612fd86ca788..bf9d18fdb1462 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -869,34 +869,32 @@ fxp_detach(device_t dev) struct fxp_softc *sc = device_get_softc(dev); int s; - /* disable interrupts */ - CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE); - s = splimp(); + /* + * Close down routes etc. + */ + ether_ifdetach(&sc->arpcom.ac_if); - if (device_is_alive(dev)) { - /* - * Stop DMA and drop transmit queue. - */ - if (bus_child_present(dev)) - fxp_stop(sc); - /* - * Close down routes etc. - */ - ether_ifdetach(&sc->arpcom.ac_if); - device_delete_child(dev, sc->miibus); - bus_generic_detach(dev); - /* - * Free all media structures. - */ - ifmedia_removeall(&sc->sc_media); + /* + * Stop DMA and drop transmit queue. + */ + if (bus_child_present(dev)) { + /* disable interrupts */ + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE); + fxp_stop(sc); } + device_delete_child(dev, sc->miibus); + bus_generic_detach(dev); + /* + * Free all media structures. + */ + ifmedia_removeall(&sc->sc_media); + splx(s); /* Release our allocated resources. */ fxp_release(sc); - return (0); } -- cgit v1.3