diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-05-08 20:33:08 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-05-08 20:33:08 +0000 |
commit | 67e72c3378f0d327f4e61685dbd9415d4c0731a2 (patch) | |
tree | a240efbd16546d5f55dec0ca140793857d3d3c94 /sys | |
parent | 34fa57004f4b21f9d683f260f1af64d1be4ba445 (diff) |
put more foo_detach() routines where they are used
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/isa/pccom.c | 32 | ||||
-rw-r--r-- | sys/dev/cardbus/com_cardbus.c | 43 | ||||
-rw-r--r-- | sys/dev/cardbus/if_fxp_cardbus.c | 30 | ||||
-rw-r--r-- | sys/dev/ic/com.c | 41 | ||||
-rw-r--r-- | sys/dev/ic/comvar.h | 3 | ||||
-rw-r--r-- | sys/dev/ic/fxp.c | 28 | ||||
-rw-r--r-- | sys/dev/ic/fxpvar.h | 3 |
7 files changed, 76 insertions, 104 deletions
diff --git a/sys/arch/i386/isa/pccom.c b/sys/arch/i386/isa/pccom.c index 9f4e9583d0e..303837c9a10 100644 --- a/sys/arch/i386/isa/pccom.c +++ b/sys/arch/i386/isa/pccom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pccom.c,v 1.57 2007/02/15 18:39:26 mickey Exp $ */ +/* $OpenBSD: pccom.c,v 1.58 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -415,36 +415,6 @@ comattach(struct device *parent, struct device *self, void *aux) } int -com_detach(struct device *self, int flags) -{ - struct com_softc *sc = (struct com_softc *)self; - int maj, mn; - - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == comopen) - break; - - /* Nuke the vnodes for any open instances. */ - mn = self->dv_unit; - vdevgone(maj, mn, mn, VCHR); - - /* XXX a symbolic constant for the cua bit would be nicer. */ - mn |= 0x80; - vdevgone(maj, mn, mn, VCHR); - - /* Detach and free the tty. */ - if (sc->sc_tty) { - ttyfree(sc->sc_tty); - } - - timeout_del(&sc->sc_dtr_tmo); - timeout_del(&sc->sc_diag_tmo); - - return (0); -} - -int com_activate(struct device *self, enum devact act) { struct com_softc *sc = (struct com_softc *)self; diff --git a/sys/dev/cardbus/com_cardbus.c b/sys/dev/cardbus/com_cardbus.c index 813fa2c681e..afc5f2d6608 100644 --- a/sys/dev/cardbus/com_cardbus.c +++ b/sys/dev/cardbus/com_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_cardbus.c,v 1.26 2006/10/12 16:35:51 grange Exp $ */ +/* $OpenBSD: com_cardbus.c,v 1.27 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: com_cardbus.c,v 1.4 2000/04/17 09:21:59 joda Exp $ */ /* @@ -372,6 +372,47 @@ com_cardbus_disable(struct com_softc *sc) } int +com_detach(self, flags) + struct device *self; + int flags; +{ + struct com_softc *sc = (struct com_softc *)self; + int maj, mn; + + sc->sc_swflags |= COM_SW_DEAD; + + /* locate the major number */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == comopen) + break; + + /* Nuke the vnodes for any open instances. */ + mn = self->dv_unit; + vdevgone(maj, mn, mn, VCHR); + + /* XXX a symbolic constant for the cua bit would be nicer. */ + mn |= 0x80; + vdevgone(maj, mn, mn, VCHR); + + /* Detach and free the tty. */ + if (sc->sc_tty) { + ttyfree(sc->sc_tty); + } + + timeout_del(&sc->sc_dtr_tmo); + timeout_del(&sc->sc_diag_tmo); +#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS + softintr_disestablish(sc->sc_si); +#else + timeout_del(&sc->sc_comsoft_tmo); +#endif + + return (0); +} + +int com_detach(struct device *, int); + +int com_cardbus_detach(struct device *self, int flags) { struct com_cardbus_softc *csc = (struct com_cardbus_softc *) self; diff --git a/sys/dev/cardbus/if_fxp_cardbus.c b/sys/dev/cardbus/if_fxp_cardbus.c index 37223d7ae18..1a3f97dc964 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.18 2006/10/12 16:35:52 grange Exp $ */ +/* $OpenBSD: if_fxp_cardbus.c,v 1.19 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: if_fxp_cardbus.c,v 1.12 2000/05/08 18:23:36 thorpej Exp $ */ /* @@ -227,6 +227,34 @@ fxp_cardbus_setup(struct fxp_softc *sc) } 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); +} + +int fxp_detach(struct fxp_softc *); + +int fxp_cardbus_detach(struct device *self, int flags) { struct fxp_softc *sc = (struct fxp_softc *) self; diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 48511d60c88..9a8d0539344 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.112 2006/06/23 06:27:11 miod Exp $ */ +/* $OpenBSD: com.c,v 1.113 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -200,45 +200,6 @@ comprobe1(iot, ioh) #endif int -com_detach(self, flags) - struct device *self; - int flags; -{ - struct com_softc *sc = (struct com_softc *)self; - int maj, mn; - - sc->sc_swflags |= COM_SW_DEAD; - - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == comopen) - break; - - /* Nuke the vnodes for any open instances. */ - mn = self->dv_unit; - vdevgone(maj, mn, mn, VCHR); - - /* XXX a symbolic constant for the cua bit would be nicer. */ - mn |= 0x80; - vdevgone(maj, mn, mn, VCHR); - - /* Detach and free the tty. */ - if (sc->sc_tty) { - ttyfree(sc->sc_tty); - } - - timeout_del(&sc->sc_dtr_tmo); - timeout_del(&sc->sc_diag_tmo); -#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS - softintr_disestablish(sc->sc_si); -#else - timeout_del(&sc->sc_comsoft_tmo); -#endif - - return (0); -} - -int com_activate(self, act) struct device *self; enum devact act; diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index 9d061140c0e..be9262c9ea6 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.40 2006/12/28 20:50:26 miod Exp $ */ +/* $OpenBSD: comvar.h,v 1.41 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -140,7 +140,6 @@ struct com_softc { int comprobe1(bus_space_tag_t, bus_space_handle_t); int comstop(struct tty *, int); int comintr(void *); -int com_detach(struct device *, int); int com_activate(struct device *, enum devact); void comdiag(void *); diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index 5c039d8ef06..aa456a14c7c 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.85 2007/03/16 15:36:45 claudio Exp $ */ +/* $OpenBSD: fxp.c,v 1.86 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -553,32 +553,6 @@ fxp_attach(struct fxp_softc *sc, const char *intrstr) return (ENOMEM); } -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); -} - /* * From NetBSD: * diff --git a/sys/dev/ic/fxpvar.h b/sys/dev/ic/fxpvar.h index 319cee8781c..f802cf27faa 100644 --- a/sys/dev/ic/fxpvar.h +++ b/sys/dev/ic/fxpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fxpvar.h,v 1.25 2006/07/01 21:48:08 brad Exp $ */ +/* $OpenBSD: fxpvar.h,v 1.26 2007/05/08 20:33:07 deraadt Exp $ */ /* $NetBSD: if_fxpvar.h,v 1.1 1997/06/05 02:01:58 thorpej Exp $ */ /* @@ -161,7 +161,6 @@ struct fxp_softc { extern int fxp_intr(void *); extern int fxp_attach(struct fxp_softc *, const char *); -extern 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)) |