Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pcmcia handle attach failure in more detail. make s...
details: https://anonhg.NetBSD.org/src/rev/72b7cde94cc2
branches: trunk
changeset: 481593:72b7cde94cc2
user: itojun <itojun%NetBSD.org@localhost>
date: Wed Feb 02 13:02:56 2000 +0000
description:
handle attach failure in more detail. make sure to
pcmcia_function_disable() on failure.
diffstat:
sys/dev/pcmcia/if_cnw.c | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
diffs (104 lines):
diff -r 23d0d4efb7c8 -r 72b7cde94cc2 sys/dev/pcmcia/if_cnw.c
--- a/sys/dev/pcmcia/if_cnw.c Wed Feb 02 12:25:13 2000 +0000
+++ b/sys/dev/pcmcia/if_cnw.c Wed Feb 02 13:02:56 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_cnw.c,v 1.5 2000/02/02 12:25:13 itojun Exp $ */
+/* $NetBSD: if_cnw.c,v 1.6 2000/02/02 13:02:56 itojun Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -204,9 +204,10 @@
int sc_active; /* Currently xmitting a packet */
int sc_resource; /* Resources alloc'ed on attach */
-#define CNW_RES_IO 1
-#define CNW_RES_MEM 2
-#define CNW_RES_NET 4
+#define CNW_RES_PCIC 1
+#define CNW_RES_IO 2
+#define CNW_RES_MEM 4
+#define CNW_RES_NET 8
};
struct cfattach cnw_ca = {
@@ -410,6 +411,7 @@
printf("%s: couldn't enable card\n", sc->sc_dev.dv_xname);
return (EIO);
}
+ sc->sc_resource |= CNW_RES_PCIC;
cnw_init(sc);
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_flags |= IFF_RUNNING;
@@ -430,6 +432,7 @@
return;
pcmcia_function_disable(sc->sc_pf);
+ sc->sc_resource &= ~CNW_RES_PCIC;
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
ifp->if_flags &= ~IFF_RUNNING;
ifp->if_timer = 0;
@@ -480,38 +483,33 @@
printf(": function enable failed\n");
return;
}
+ sc->sc_resource |= CNW_RES_PCIC;
/* Map I/O register and "memory" */
if (pcmcia_io_alloc(sc->sc_pf, 0, CNW_IO_SIZE, CNW_IO_SIZE,
&sc->sc_pcioh) != 0) {
printf(": can't allocate i/o space\n");
- return;
+ goto fail;
}
if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_IO16, 0,
CNW_IO_SIZE, &sc->sc_pcioh, &sc->sc_iowin) != 0) {
+ printf(": can't map i/o space\n");
pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
- printf(": can't map i/o space\n");
- return;
+ goto fail;
}
sc->sc_iot = sc->sc_pcioh.iot;
sc->sc_ioh = sc->sc_pcioh.ioh;
sc->sc_resource |= CNW_RES_IO;
if (pcmcia_mem_alloc(sc->sc_pf, CNW_MEM_SIZE, &sc->sc_pcmemh) != 0) {
printf(": can't allocate memory\n");
- pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
- pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
- sc->sc_resource = 0;
- return;
+ goto fail;
}
if (pcmcia_mem_map(sc->sc_pf, PCMCIA_MEM_COMMON, CNW_MEM_ADDR,
CNW_MEM_SIZE, &sc->sc_pcmemh, &sc->sc_memoff,
&sc->sc_memwin) != 0) {
printf(": can't map memory\n");
pcmcia_mem_free(sc->sc_pf, &sc->sc_pcmemh);
- pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
- pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
- sc->sc_resource = 0;
- return;
+ goto fail;
}
sc->sc_memt = sc->sc_pcmemh.memt;
sc->sc_memh = sc->sc_pcmemh.memh;
@@ -559,6 +557,19 @@
/* Disable the card now, and turn it on when the interface goes up */
pcmcia_function_disable(sc->sc_pf);
+ sc->sc_resource &= ~CNW_RES_PCIC;
+ return;
+
+fail:
+ if ((sc->sc_resource & CNW_RES_IO) != 0) {
+ pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
+ pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
+ sc->sc_resource &= ~CNW_RES_IO;
+ }
+ if ((sc->sc_resource & CNW_RES_PCIC) != 0) {
+ pcmcia_function_disable(sc->sc_pf);
+ sc->sc_resource &= ~CNW_RES_PCIC;
+ }
}
/*
Home |
Main Index |
Thread Index |
Old Index