From f65dd5415253da95d28e9fd9e03aa03f1d8c462f Mon Sep 17 00:00:00 2001 From: mycroft Date: Mon, 9 Aug 2004 18:51:32 +0000 Subject: [PATCH] Correct the intr_establish order here. --- sys/dev/pcmcia/if_ray.c | 21 +++++++++++---------- sys/dev/pcmcia/isic_pcmcia.c | 27 ++++++++++----------------- sys/dev/pcmcia/pcmcom.c | 17 ++++++++++------- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/sys/dev/pcmcia/if_ray.c b/sys/dev/pcmcia/if_ray.c index 089c1c8ebd5e..8d968c763b17 100644 --- a/sys/dev/pcmcia/if_ray.c +++ b/sys/dev/pcmcia/if_ray.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ray.c,v 1.46 2004/08/07 05:35:50 mycroft Exp $ */ +/* $NetBSD: if_ray.c,v 1.47 2004/08/09 18:51:32 mycroft Exp $ */ /* * Copyright (c) 2000 Christian E. Hopps * All rights reserved. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.46 2004/08/07 05:35:50 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.47 2004/08/09 18:51:32 mycroft Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -707,14 +707,15 @@ ray_enable(sc) RAY_DPRINTF(("%s: enable\n", sc->sc_xname)); - if ((error = ray_init(sc)) == 0) { - sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, - ray_intr, sc); - if (sc->sc_ih == NULL) { - ray_stop(sc); - return (EIO); - } - } + sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, + ray_intr, sc); + if (sc->sc_ih == NULL) + return (EIO); + + error = ray_init(sc); + if (error) + pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); + return (error); } diff --git a/sys/dev/pcmcia/isic_pcmcia.c b/sys/dev/pcmcia/isic_pcmcia.c index d53b89c88805..8b71a4b9e159 100644 --- a/sys/dev/pcmcia/isic_pcmcia.c +++ b/sys/dev/pcmcia/isic_pcmcia.c @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isic_pcmcia.c,v 1.23 2004/01/04 12:41:46 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isic_pcmcia.c,v 1.24 2004/08/09 18:51:32 mycroft Exp $"); #include #include @@ -205,7 +205,6 @@ isic_pcmcia_attach(parent, self, aux) struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; const struct isic_pcmcia_card_entry * cde; - int s; psc->sc_pf = pa->pf; cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); @@ -222,34 +221,28 @@ isic_pcmcia_attach(parent, self, aux) /* Enable the card */ pcmcia_function_init(pa->pf, cfe); + psc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_NET, isicintr, sc); pcmcia_function_enable(pa->pf); if (!cde->attach(psc, cfe, pa)) { - pcmcia_function_disable(psc->sc_pf); printf("%s: attach failed, card-specific attach unsuccesful\n", psc->sc_isic.sc_dev.dv_xname); - return; + goto fail; } - /* XXX - we generate interrupts during card initialization. - Block them for now, until the handler is established. */ - s = splhigh(); - /* MI initilization */ sc->sc_cardtyp = cde->card_type; - if (isic_pcmcia_isdn_attach(sc, cde->name) == 0) { - /* setup interrupt */ - psc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_NET, isicintr, sc); - } else { - pcmcia_function_disable(psc->sc_pf); - splx(s); - printf("%s: attach failed, couldn't establish interrupt\n", + if (isic_pcmcia_isdn_attach(sc, cde->name)) { + printf("%s: attach failed, generic attach unsuccesful\n", psc->sc_isic.sc_dev.dv_xname); - return; + goto fail; } - splx(s); return; + +fail: + pcmcia_function_disable(psc->sc_pf); + pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); } static int diff --git a/sys/dev/pcmcia/pcmcom.c b/sys/dev/pcmcia/pcmcom.c index f1562ca61ec4..0267b93fa1a4 100644 --- a/sys/dev/pcmcia/pcmcom.c +++ b/sys/dev/pcmcia/pcmcom.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcmcom.c,v 1.15 2004/08/08 23:17:13 mycroft Exp $ */ +/* $NetBSD: pcmcom.c,v 1.16 2004/08/09 18:51:32 mycroft Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -51,7 +51,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcmcom.c,v 1.15 2004/08/08 23:17:13 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcmcom.c,v 1.16 2004/08/09 18:51:32 mycroft Exp $"); #include #include @@ -392,9 +392,9 @@ int pcmcom_enable(sc) struct pcmcom_softc *sc; { + int error; - sc->sc_enabled_count++; - if (sc->sc_enabled_count > 1) + if (sc->sc_enabled_count++ != 0) return (0); /* Establish the interrupt. */ @@ -406,7 +406,11 @@ pcmcom_enable(sc) return (1); } - return (pcmcia_function_enable(sc->sc_pf)); + error = pcmcia_function_enable(sc->sc_pf); + if (error) + pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); + + return (error); } void @@ -414,8 +418,7 @@ pcmcom_disable(sc) struct pcmcom_softc *sc; { - sc->sc_enabled_count--; - if (sc->sc_enabled_count != 0) + if (--sc->sc_enabled_count != 0) return; pcmcia_function_disable(sc->sc_pf);