summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfgsch <fgsch@openbsd.org>1999-02-13 00:59:28 +0000
committerfgsch <fgsch@openbsd.org>1999-02-13 00:59:28 +0000
commit4610e7de5e00532fc681ef3416b44fa04d95f2e1 (patch)
treee8ee2ca3b52e2db6e7ec105a24f8e1a84f966b07
parentVerify that keys and IVs are in hex. (diff)
downloadwireguard-openbsd-4610e7de5e00532fc681ef3416b44fa04d95f2e1.tar.xz
wireguard-openbsd-4610e7de5e00532fc681ef3416b44fa04d95f2e1.zip
If the card is not present be sure to always call bus_space_unmap on exit.
-rw-r--r--sys/dev/isa/if_ex.c20
-rw-r--r--sys/dev/isa/wds.c47
2 files changed, 39 insertions, 28 deletions
diff --git a/sys/dev/isa/if_ex.c b/sys/dev/isa/if_ex.c
index d8fad73e918..ff1b73fefdc 100644
--- a/sys/dev/isa/if_ex.c
+++ b/sys/dev/isa/if_ex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ex.c,v 1.2 1997/11/09 22:21:22 gene Exp $ */
+/* $OpenBSD: if_ex.c,v 1.3 1999/02/13 01:02:21 fgsch Exp $ */
/*
* Copyright (c) 1997, Donald A. Schmidt
* Copyright (c) 1996, Javier Martín Rueda (jmrueda@diatel.upm.es)
@@ -168,10 +168,6 @@ look_for_card(ia, sc)
{
int count1, count2;
- sc->sc_ioh = ia->ia_iot;
- if(bus_space_map(ia->ia_iot, ia->ia_iobase, EX_IOSIZE, 0, &sc->sc_ioh))
- return(0);
-
/*
* Check for the i82595 signature, and check that the round robin
* counter actually advances.
@@ -183,10 +179,8 @@ look_for_card(ia, sc)
count2 = ISA_GET(ID_REG);
if ((count2 & Counter_bits) == ((count1 + 0xc0) & Counter_bits))
return(1);
- else {
- bus_space_unmap(sc->sc_iot, sc->sc_ioh, EX_IOSIZE);
+ else
return(0);
- }
}
@@ -197,6 +191,8 @@ ex_probe(parent, match, aux)
{
struct ex_softc *sc = match;
struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
int iobase;
u_short eaddr_tmp;
@@ -207,13 +203,17 @@ ex_probe(parent, match, aux)
iobase = ia->ia_iobase;
if ((iobase >= 0x200) && (iobase <= 0x3a0)) {
- if (look_for_card(ia, sc) == 0)
+ if(bus_space_map(iot, iobase, EX_IOSIZE, 0, &ioh))
+ return(0);
+
+ if (!look_for_card(ia, sc)) {
+ bus_space_unmap(iot, ioh, EX_IOSIZE);
return(0);
+ }
} else
return(0);
ia->ia_iosize = EX_IOSIZE;
-/* ia->ia_iobase = iobase; */
/*
* Reset the card.
diff --git a/sys/dev/isa/wds.c b/sys/dev/isa/wds.c
index b771ee6b3fa..e70f910f5f1 100644
--- a/sys/dev/isa/wds.c
+++ b/sys/dev/isa/wds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wds.c,v 1.15 1999/01/24 15:58:54 mickey Exp $ */
+/* $OpenBSD: wds.c,v 1.16 1999/02/13 00:59:28 fgsch Exp $ */
/* $NetBSD: wds.c,v 1.13 1996/11/03 16:20:31 mycroft Exp $ */
#undef WDSDIAG
@@ -247,14 +247,24 @@ wdsprobe(parent, match, aux)
void *match, *aux;
{
register struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
+ int rv;
+
+ if (bus_space_map(iot, ia->ia_iobase, WDS_IO_PORTS, 0, &ioh))
+ return (0);
/* See if there is a unit at this location. */
- if (wds_find(ia, NULL) != 0)
- return 0;
+ rv = wds_find(ia, NULL);
- ia->ia_msize = 0;
- ia->ia_iosize = WDS_IO_PORTS;
- return 1;
+ bus_space_unmap(iot, ioh, WDS_IO_PORTS);
+
+ if (rv) {
+ ia->ia_msize = 0;
+ ia->ia_iosize = WDS_IO_PORTS;
+ }
+
+ return (rv);
}
int
@@ -278,8 +288,15 @@ wdsattach(parent, self, aux)
{
struct isa_attach_args *ia = aux;
struct wds_softc *sc = (void *)self;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
- if (wds_find(ia, sc) != 0)
+ if (bus_space_map(iot, ia->ia_iobase, WDS_IO_PORTS, 0, &ioh)) {
+ printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
+ return;
+ }
+
+ if (!wds_find(ia, sc))
panic("wdsattach: wds_find of %s failed", self->dv_xname);
wds_init(sc);
@@ -841,11 +858,6 @@ wds_find(ia, sc)
u_char c;
int i;
- /* XXXXX */
-
- if (bus_space_map(iot, ia->ia_iobase, WDS_IO_PORTS, 0, &ioh))
- return (1);
-
/*
* Sending a command causes the CMDRDY bit to clear.
*/
@@ -855,12 +867,12 @@ wds_find(ia, sc)
goto ready;
delay(10);
}
- return (1);
+ return (0);
ready:
bus_space_write_1(iot, ioh, WDS_CMD, WDSC_NOOP);
if (bus_space_read_1(iot, ioh, WDS_STAT) & WDSS_RDY)
- return 1;
+ return (0);
bus_space_write_1(iot, ioh, WDS_HCR, WDSH_SCSIRESET|WDSH_ASCRESET);
delay(10000);
@@ -886,7 +898,7 @@ ready:
if ((bus_space_read_1(iot, ioh, WDS_STAT) & (WDSS_RDY)) !=
WDSS_RDY) {
printf(" failed\n");
- return (1);
+ return (0);
}
printf("\n");
}
@@ -900,10 +912,9 @@ ready:
sc->sc_ioh = ioh;
sc->sc_irq = ia->ia_irq;
sc->sc_drq = ia->ia_drq;
- } else
- bus_space_unmap(iot, ioh, WDS_IO_PORTS);
+ }
- return (0);
+ return (1);
}
/*