Avoid splx() with uninitialized priority level by duplicating some code

to get rid of gotos.

While doing that, add more verbosity on what failed if attach is not succesful.
This commit is contained in:
pooka 2003-10-28 17:35:30 +00:00
parent 57755c156a
commit aa476f1628
1 changed files with 20 additions and 13 deletions

View File

@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: isic_pcmcia.c,v 1.20 2003/10/03 16:38:44 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: isic_pcmcia.c,v 1.21 2003/10/28 17:35:30 pooka Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@ -213,15 +213,22 @@ isic_pcmcia_attach(parent, self, aux)
/* Which card is it? */
cde = find_matching_card(pa);
if (cde == NULL)
goto bad2; /* oops - not found?!? */
if (cde == NULL) {
printf("%s: attach failed, couldn't find matching card\n",
psc->sc_isic.sc_dev.dv_xname);
return;
}
/* Enable the card */
pcmcia_function_init(pa->pf, cfe);
pcmcia_function_enable(pa->pf);
if (!cde->attach(psc, cfe, pa))
goto bad; /* Ooops ? */
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;
}
/* Announce card name */
printf(": %s\n", cde->name);
@ -229,22 +236,22 @@ isic_pcmcia_attach(parent, self, aux)
/* 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
goto bad;
} else {
pcmcia_function_disable(psc->sc_pf);
splx(s);
printf("%s: attach failed, couldn't establish interrupt\n",
psc->sc_isic.sc_dev.dv_xname);
return;
}
splx(s);
return;
bad:
pcmcia_function_disable(psc->sc_pf);
splx(s);
bad2:
printf("%s: attach failed\n", psc->sc_isic.sc_dev.dv_xname);
}
static int