/* * Cardbus detach function: deallocate all resources */ int re_cardbus_detach(struct device *self, int flags) { struct re_cardbus_softc *csc = (void *)self; struct rl_softc *sc = &csc->sc_rl; struct cardbus_devfunc *ct = csc->ct; struct ifnet *ifp = &sc->sc_arpcom.ac_if; /* Remove timeout handler */ timeout_del(&sc->timer_handle); /* Detach PHY */ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete media stuff */ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); /* Disable interrupts */ if (csc->sc_ih != NULL) cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih); /* Free cardbus resources */ Cardbus_mapreg_unmap(ct, csc->sc_bar_reg, sc->rl_btag, sc->rl_bhandle, csc->sc_mapsize); return (0); }
int re_pci_detach(struct device *self, int flags) { struct re_pci_softc *psc = (struct re_pci_softc *)self; struct rl_softc *sc = &psc->sc_rl; struct ifnet *ifp = &sc->sc_arpcom.ac_if; /* Remove timeout handler */ timeout_del(&sc->timer_handle); /* Detach PHY */ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete media stuff */ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); /* Disable interrupts */ if (psc->sc_ih != NULL) pci_intr_disestablish(psc->sc_pc, psc->sc_ih); /* Free pci resources */ bus_space_unmap(sc->rl_btag, sc->rl_bhandle, psc->sc_iosize); return (0); }
int vte_detach(struct device *self, int flags) { struct vte_softc *sc = (struct vte_softc *)self; struct ifnet *ifp = &sc->sc_arpcom.ac_if; int s; s = splnet(); vte_stop(sc); splx(s); mii_detach(&sc->sc_miibus, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete all remaining media. */ ifmedia_delete_instance(&sc->sc_miibus.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); vte_dma_free(sc); if (sc->sc_irq_handle != NULL) { pci_intr_disestablish(sc->sc_pct, sc->sc_irq_handle); sc->sc_irq_handle = NULL; } return (0); }
/* detach */ int url_detach(device_t self, int flags) { struct url_softc *sc = device_private(self); struct ifnet *ifp = GET_IFP(sc); int s; DPRINTF(("%s: %s: enter\n", device_xname(sc->sc_dev), __func__)); /* Detached before attached finished */ if (!sc->sc_attached) return (0); callout_stop(&sc->sc_stat_ch); /* Remove any pending tasks */ usb_rem_task(sc->sc_udev, &sc->sc_tick_task); usb_rem_task(sc->sc_udev, &sc->sc_stop_task); s = splusb(); if (--sc->sc_refcnt >= 0) { /* Wait for processes to go away */ usb_detach_waitold(sc->sc_dev); } if (ifp->if_flags & IFF_RUNNING) url_stop(GET_IFP(sc), 1); rnd_detach_source(&sc->rnd_source); mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); #ifdef DIAGNOSTIC if (sc->sc_pipe_tx != NULL) aprint_debug_dev(self, "detach has active tx endpoint.\n"); if (sc->sc_pipe_rx != NULL) aprint_debug_dev(self, "detach has active rx endpoint.\n"); if (sc->sc_pipe_intr != NULL) aprint_debug_dev(self, "detach has active intr endpoint.\n"); #endif sc->sc_attached = 0; splx(s); rw_destroy(&sc->sc_mii_rwlock); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); return (0); }
/* * rtk_detach: * Detach a rtk interface. */ int rtk_detach(struct rtk_softc *sc) { struct ifnet *ifp = &sc->ethercom.ec_if; struct rtk_tx_desc *txd; int i; /* * Succeed now if there isn't any work to do. */ if ((sc->sc_flags & RTK_ATTACHED) == 0) return 0; /* Unhook our tick handler. */ callout_stop(&sc->rtk_tick_ch); /* Detach all PHYs. */ mii_detach(&sc->mii, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete all remaining media. */ ifmedia_delete_instance(&sc->mii.mii_media, IFM_INST_ANY); rnd_detach_source(&sc->rnd_source); ether_ifdetach(ifp); if_detach(ifp); for (i = 0; i < RTK_TX_LIST_CNT; i++) { txd = &sc->rtk_tx_descs[i]; if (txd->txd_dmamap != NULL) bus_dmamap_destroy(sc->sc_dmat, txd->txd_dmamap); } bus_dmamap_destroy(sc->sc_dmat, sc->recv_dmamap); bus_dmamem_unmap(sc->sc_dmat, sc->rtk_rx_buf, RTK_RXBUFLEN + 16); bus_dmamem_free(sc->sc_dmat, &sc->sc_dmaseg, sc->sc_dmanseg); /* we don't want to run again */ sc->sc_flags &= ~RTK_ATTACHED; return 0; }
void dl10019_media_fini(struct dp8390_softc *sc) { mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); }
/* * ae_detach: * * Detach a device interface. */ int ae_detach(device_t self, int flags) { struct ae_softc *sc = device_private(self); struct ifnet *ifp = &sc->sc_ethercom.ec_if; struct ae_rxsoft *rxs; struct ae_txsoft *txs; int i; /* * Succeed now if there isn't any work to do. */ if ((sc->sc_flags & AE_ATTACHED) == 0) return (0); /* Unhook our tick handler. */ if (sc->sc_tick) callout_stop(&sc->sc_tick_callout); /* Detach all PHYs */ mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete all remaining media. */ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); rnd_detach_source(&sc->sc_rnd_source); ether_ifdetach(ifp); if_detach(ifp); for (i = 0; i < AE_NRXDESC; i++) { rxs = &sc->sc_rxsoft[i]; if (rxs->rxs_mbuf != NULL) { bus_dmamap_unload(sc->sc_dmat, rxs->rxs_dmamap); m_freem(rxs->rxs_mbuf); rxs->rxs_mbuf = NULL; } bus_dmamap_destroy(sc->sc_dmat, rxs->rxs_dmamap); } for (i = 0; i < AE_TXQUEUELEN; i++) { txs = &sc->sc_txsoft[i]; if (txs->txs_mbuf != NULL) { bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap); m_freem(txs->txs_mbuf); txs->txs_mbuf = NULL; } bus_dmamap_destroy(sc->sc_dmat, txs->txs_dmamap); } bus_dmamap_unload(sc->sc_dmat, sc->sc_cddmamap); bus_dmamap_destroy(sc->sc_dmat, sc->sc_cddmamap); bus_dmamem_unmap(sc->sc_dmat, (void *)sc->sc_control_data, sizeof(struct ae_control_data)); bus_dmamem_free(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg); shutdownhook_disestablish(sc->sc_sdhook); powerhook_disestablish(sc->sc_powerhook); bus_space_unmap(sc->sc_st, sc->sc_sh, sc->sc_size); return (0); }