From b3284db37f807ede1a336a6386d90497400711fd Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 2 Jun 2009 16:50:21 +0000 Subject: Make fxp at pci detachable; untested. --- sys/dev/ic/fxp.c | 28 +++++++++++++++++++++++++++- sys/dev/ic/fxpvar.h | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'sys/dev/ic') diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index e60ebab5b49..8d7f6256207 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.94 2008/11/28 02:44:17 brad Exp $ */ +/* $OpenBSD: fxp.c,v 1.95 2009/06/02 16:50:20 jsg Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -1052,6 +1052,32 @@ fxp_stats_update(void *arg) timeout_add_sec(&sc->stats_update_to, 1); } +int +fxp_detach(struct fxp_softc *sc) +{ + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + + /* Unhook our tick handler. */ + timeout_del(&sc->stats_update_to); + + /* Detach any PHYs we might have. */ + if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) + mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); + + /* Delete any remaining media. */ + ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); + + ether_ifdetach(ifp); + if_detach(ifp); + + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_powerhook != NULL) + powerhook_disestablish(sc->sc_powerhook); + + return (0); +} + /* * Stop the interface. Cancels the statistics updater and resets * the interface. diff --git a/sys/dev/ic/fxpvar.h b/sys/dev/ic/fxpvar.h index 358e8e3f697..e88d580ec8c 100644 --- a/sys/dev/ic/fxpvar.h +++ b/sys/dev/ic/fxpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fxpvar.h,v 1.28 2008/02/21 03:58:07 brad Exp $ */ +/* $OpenBSD: fxpvar.h,v 1.29 2009/06/02 16:50:20 jsg Exp $ */ /* $NetBSD: if_fxpvar.h,v 1.1 1997/06/05 02:01:58 thorpej Exp $ */ /* @@ -157,6 +157,7 @@ struct fxp_softc { extern int fxp_intr(void *); extern int fxp_attach(struct fxp_softc *, const char *); +int fxp_detach(struct fxp_softc *); #define FXP_RXMAP_GET(sc) ((sc)->sc_rxmaps[(sc)->sc_rxfree++]) #define FXP_RXMAP_PUT(sc,map) ((sc)->sc_rxmaps[--(sc)->sc_rxfree] = (map)) -- cgit v1.2.3