summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2009-06-02 16:50:21 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2009-06-02 16:50:21 +0000
commitb3284db37f807ede1a336a6386d90497400711fd (patch)
tree0ed8e6e68fdb6e94746074ac95248bbf5b7ec680 /sys/dev/ic
parentcaba12193a3fbed4b1793760f627ce31a39716f3 (diff)
Make fxp at pci detachable; untested.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/fxp.c28
-rw-r--r--sys/dev/ic/fxpvar.h3
2 files changed, 29 insertions, 2 deletions
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))