summaryrefslogtreecommitdiff
path: root/sys/dev/cardbus
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-10-15 17:54:57 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-10-15 17:54:57 +0000
commite146ad033c7b64925ffa948f37bf1b536392e65c (patch)
treeebd18c972b363ff177bdd0820fa8d77bdaa2321e /sys/dev/cardbus
parent2faa5c93c1cb8fe9a551a57cbe7ccee57638b318 (diff)
Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the interrupt handlers not trust registers that go away. read over very carefully by dms, tested by me
Diffstat (limited to 'sys/dev/cardbus')
-rw-r--r--sys/dev/cardbus/if_dc_cardbus.c10
-rw-r--r--sys/dev/cardbus/if_fxp_cardbus.c33
-rw-r--r--sys/dev/cardbus/if_xl_cardbus.c35
3 files changed, 23 insertions, 55 deletions
diff --git a/sys/dev/cardbus/if_dc_cardbus.c b/sys/dev/cardbus/if_dc_cardbus.c
index 987c2efcc9b..616b6bb5e1e 100644
--- a/sys/dev/cardbus/if_dc_cardbus.c
+++ b/sys/dev/cardbus/if_dc_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_dc_cardbus.c,v 1.29 2009/06/26 16:58:46 deraadt Exp $ */
+/* $OpenBSD: if_dc_cardbus.c,v 1.30 2009/10/15 17:54:56 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -243,20 +243,16 @@ dc_cardbus_detach(struct device *self, int flags)
struct dc_cardbus_softc *csc = (struct dc_cardbus_softc *)self;
struct dc_softc *sc = &csc->sc_dc;
struct cardbus_devfunc *ct = csc->sc_ct;
- int rv = 0;
-
- rv = dc_detach(sc);
- if (rv)
- return (rv);
cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, sc->sc_ih);
+ dc_detach(sc);
/* unmap cardbus resources */
Cardbus_mapreg_unmap(ct,
csc->sc_actype == CARDBUS_IO_ENABLE ? PCI_CBIO : PCI_CBMEM,
sc->dc_btag, sc->dc_bhandle, csc->sc_mapsize);
- return (rv);
+ return (0);
}
void
diff --git a/sys/dev/cardbus/if_fxp_cardbus.c b/sys/dev/cardbus/if_fxp_cardbus.c
index 3d7a0c02074..cb37464a238 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.23 2009/06/02 16:50:20 jsg Exp $ */
+/* $OpenBSD: if_fxp_cardbus.c,v 1.24 2009/10/15 17:54:56 deraadt Exp $ */
/* $NetBSD: if_fxp_cardbus.c,v 1.12 2000/05/08 18:23:36 thorpej Exp $ */
/*
@@ -219,28 +219,15 @@ fxp_cardbus_detach(struct device *self, int flags)
struct fxp_softc *sc = (struct fxp_softc *) self;
struct fxp_cardbus_softc *csc = (struct fxp_cardbus_softc *) self;
struct cardbus_devfunc *ct = csc->ct;
- int rv, reg;
+ int reg;
-#ifdef DIAGNOSTIC
- if (ct == NULL)
- panic("%s: data structure lacks", sc->sc_dev.dv_xname);
-#endif
+ cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, sc->sc_ih);
+ fxp_detach(sc);
- rv = fxp_detach(sc);
- if (rv == 0) {
- /*
- * Unhook the interrupt handler.
- */
- cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, sc->sc_ih);
-
- /*
- * release bus space and close window
- */
- if (csc->base0_reg)
- reg = CARDBUS_BASE0_REG;
- else
- reg = CARDBUS_BASE1_REG;
- Cardbus_mapreg_unmap(ct, reg, sc->sc_st, sc->sc_sh, csc->size);
- }
- return (rv);
+ if (csc->base0_reg)
+ reg = CARDBUS_BASE0_REG;
+ else
+ reg = CARDBUS_BASE1_REG;
+ Cardbus_mapreg_unmap(ct, reg, sc->sc_st, sc->sc_sh, csc->size);
+ return (0);
}
diff --git a/sys/dev/cardbus/if_xl_cardbus.c b/sys/dev/cardbus/if_xl_cardbus.c
index d3d663aad0d..c3bf4fc88e8 100644
--- a/sys/dev/cardbus/if_xl_cardbus.c
+++ b/sys/dev/cardbus/if_xl_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_xl_cardbus.c,v 1.21 2009/06/02 07:55:08 deraadt Exp $ */
+/* $OpenBSD: if_xl_cardbus.c,v 1.22 2009/10/15 17:54:56 deraadt Exp $ */
/* $NetBSD: if_xl_cardbus.c,v 1.13 2000/03/07 00:32:52 mycroft Exp $ */
/*
@@ -299,31 +299,16 @@ xl_cardbus_detach(struct device *self, int arg)
struct xl_cardbus_softc *csc = (void *)self;
struct xl_softc *sc = &csc->sc_softc;
struct cardbus_devfunc *ct = csc->sc_ct;
- int rv = 0;
-#if defined(DIAGNOSTIC)
- if (ct == NULL) {
- panic("%s: data structure lacks", sc->sc_dev.dv_xname);
- }
-#endif
-
- rv = xl_detach(sc);
- if (rv == 0) {
- /*
- * Unhook the interrupt handler.
- */
- cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf,
- sc->xl_intrhand);
-
- if (csc->sc_cardtype == XL_CARDBUS_CYCLONE) {
- Cardbus_mapreg_unmap(ct, CARDBUS_BASE2_REG,
- csc->sc_funct, csc->sc_funch, csc->sc_funcsize);
- }
-
- Cardbus_mapreg_unmap(ct, CARDBUS_BASE0_REG, sc->xl_btag,
- sc->xl_bhandle, csc->sc_mapsize);
- }
- return (rv);
+ cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf,
+ sc->xl_intrhand);
+ xl_detach(sc);
+ if (csc->sc_cardtype == XL_CARDBUS_CYCLONE)
+ Cardbus_mapreg_unmap(ct, CARDBUS_BASE2_REG,
+ csc->sc_funct, csc->sc_funch, csc->sc_funcsize);
+ Cardbus_mapreg_unmap(ct, CARDBUS_BASE0_REG, sc->xl_btag,
+ sc->xl_bhandle, csc->sc_mapsize);
+ return (0);
}
void