summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2000-09-17 17:08:17 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2000-09-17 17:08:17 +0000
commit87c84913b9f921687fcacd056b39b11d03e810b6 (patch)
tree029572d9cf47d34f16cd3c8c6196e208f75ed34c /sys
parent5c75639280ec653899e03f288445ec216c10e72b (diff)
Support detach of fxp devices to allow ejection of Intel CardBus adapters.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/cardbus/if_fxp_cardbus.c4
-rw-r--r--sys/dev/ic/fxp.c31
-rw-r--r--sys/dev/ic/fxpvar.h5
3 files changed, 33 insertions, 7 deletions
diff --git a/sys/dev/cardbus/if_fxp_cardbus.c b/sys/dev/cardbus/if_fxp_cardbus.c
index 1b53d9c658e..a97eed994c9 100644
--- a/sys/dev/cardbus/if_fxp_cardbus.c
+++ b/sys/dev/cardbus/if_fxp_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fxp_cardbus.c,v 1.1 2000/09/17 05:11:12 aaron Exp $ */
+/* $OpenBSD: if_fxp_cardbus.c,v 1.2 2000/09/17 17:08:16 aaron Exp $ */
/* $NetBSD: if_fxp_cardbus.c,v 1.12 2000/05/08 18:23:36 thorpej Exp $ */
/*
@@ -248,9 +248,7 @@ fxp_cardbus_detach(self, flags)
panic("%s: data structure lacks\n", sc->sc_dev.dv_xname);
#endif
-#if 0
rv = fxp_detach(sc);
-#endif
if (rv == 0) {
/*
* Unhook the interrupt handler.
diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c
index 8397b229b80..7113e1a29dd 100644
--- a/sys/dev/ic/fxp.c
+++ b/sys/dev/ic/fxp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fxp.c,v 1.8 2000/08/02 18:50:17 aaron Exp $ */
+/* $OpenBSD: fxp.c,v 1.9 2000/09/17 17:08:16 aaron Exp $ */
/* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */
/*
@@ -412,12 +412,12 @@ fxp_attach_common(sc, enaddr, intrstr)
* doing do could allow DMA to corrupt kernel memory during the
* reboot before the driver initializes.
*/
- shutdownhook_establish(fxp_shutdown, sc);
+ sc->sc_sdhook = shutdownhook_establish(fxp_shutdown, sc);
/*
* Add suspend hook, for similiar reasons..
*/
- powerhook_establish(fxp_power, sc);
+ sc->sc_powerhook = powerhook_establish(fxp_power, sc);
/*
* Initialize timeout for statistics update.
@@ -441,6 +441,31 @@ fxp_attach_common(sc, enaddr, intrstr)
return (ENOMEM);
}
+int
+fxp_detach(sc)
+ struct fxp_softc *sc;
+{
+ struct ifnet *ifp = &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);
+
+ shutdownhook_disestablish(sc->sc_sdhook);
+ powerhook_disestablish(sc->sc_powerhook);
+
+ return (0);
+}
+
/*
* From NetBSD:
*
diff --git a/sys/dev/ic/fxpvar.h b/sys/dev/ic/fxpvar.h
index ddeefcb8515..f41abdc9755 100644
--- a/sys/dev/ic/fxpvar.h
+++ b/sys/dev/ic/fxpvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fxpvar.h,v 1.3 2000/07/20 16:22:26 ho Exp $ */
+/* $OpenBSD: fxpvar.h,v 1.4 2000/09/17 17:08:16 aaron Exp $ */
/* $NetBSD: if_fxpvar.h,v 1.1 1997/06/05 02:01:58 thorpej Exp $ */
/*
@@ -65,6 +65,8 @@ struct fxp_softc {
int phy_10Mbps_only; /* PHY is 10Mbps-only device */
int eeprom_size; /* size of serial EEPROM */
int not_82557; /* yes if we are 82558/82559 */
+ void *sc_sdhook; /* shutdownhook */
+ void *sc_powerhook; /* powerhook */
};
/* Macros to ease CSR access. */
@@ -83,3 +85,4 @@ struct fxp_softc {
extern int fxp_intr __P((void *));
extern int fxp_attach_common __P((struct fxp_softc *, u_int8_t *, const char *));
+extern int fxp_detach __P((struct fxp_softc *));