summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-07-12 21:27:10 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-07-12 21:27:10 +0000
commit5a3e7a6a35587f07eeead2f43a4e0ba30574e7ad (patch)
treeed0d554ed209e0ca596afb1b1bd9a68b82162126 /sys
parent2fc0ff2bf45ae3e0df70d0a66948f141b1b47b65 (diff)
Don't attach when the PROM didn't give us an interrupt. Fix printed messages
in error paths while I'm there. Eliminate a fairly useless local variable as well. ok miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/sbus/if_gem_sbus.c21
-rw-r--r--sys/dev/sbus/if_hme_sbus.c32
2 files changed, 28 insertions, 25 deletions
diff --git a/sys/dev/sbus/if_gem_sbus.c b/sys/dev/sbus/if_gem_sbus.c
index 7c6e2b19c43..d36cbd1c70c 100644
--- a/sys/dev/sbus/if_gem_sbus.c
+++ b/sys/dev/sbus/if_gem_sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gem_sbus.c,v 1.5 2008/11/07 17:44:14 brad Exp $ */
+/* $OpenBSD: if_gem_sbus.c,v 1.6 2009/07/12 21:27:09 kettenis Exp $ */
/* $NetBSD: if_gem_sbus.c,v 1.1 2006/11/24 13:23:32 martin Exp $ */
/*-
@@ -92,16 +92,20 @@ gemattach_sbus(struct device *parent, struct device *self, void *aux)
struct sbus_attach_args *sa = aux;
struct gem_sbus_softc *gsc = (void *)self;
struct gem_softc *sc = &gsc->gsc_gem;
- /* XXX the following declarations should be elsewhere */
+ /* XXX the following declaration should be elsewhere */
extern void myetheraddr(u_char *);
/* Pass on the bus tags */
sc->sc_bustag = sa->sa_bustag;
sc->sc_dmatag = sa->sa_dmatag;
+ if (sa->sa_nintr < 1) {
+ printf(": no interrupt\n");
+ return;
+ }
+
if (sa->sa_nreg < 2) {
- printf("%s: only %d register sets\n",
- self->dv_xname, sa->sa_nreg);
+ printf(": only %d register sets\n", sa->sa_nreg);
return;
}
@@ -118,14 +122,14 @@ gemattach_sbus(struct device *parent, struct device *self, void *aux)
(bus_addr_t)sa->sa_reg[0].sbr_offset,
(bus_size_t)sa->sa_reg[0].sbr_size, 0, 0,
&sc->sc_h2) != 0) {
- printf("%s: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot,
(bus_addr_t)sa->sa_reg[1].sbr_offset,
(bus_size_t)sa->sa_reg[1].sbr_size, 0, 0,
&sc->sc_h1) != 0) {
- printf("%s: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
@@ -142,9 +146,8 @@ gemattach_sbus(struct device *parent, struct device *self, void *aux)
GEM_SBUS_CFG_BSIZE128|GEM_SBUS_CFG_PARITY|GEM_SBUS_CFG_BMODE64);
/* Establish interrupt handler */
- if (sa->sa_nintr != 0)
- (void)bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET, 0,
- gem_intr, sc, self->dv_xname);
+ bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET, 0, gem_intr,
+ sc, self->dv_xname);
gem_config(sc);
}
diff --git a/sys/dev/sbus/if_hme_sbus.c b/sys/dev/sbus/if_hme_sbus.c
index dc40b1c5730..9ab41c1550c 100644
--- a/sys/dev/sbus/if_hme_sbus.c
+++ b/sys/dev/sbus/if_hme_sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_hme_sbus.c,v 1.12 2008/06/26 05:42:18 ray Exp $ */
+/* $OpenBSD: if_hme_sbus.c,v 1.13 2009/07/12 21:27:09 kettenis Exp $ */
/* $NetBSD: if_hme_sbus.c,v 1.6 2001/02/28 14:52:48 mrg Exp $ */
/*-
@@ -93,19 +93,20 @@ hmeattach_sbus(struct device *parent, struct device *self, void *aux)
struct hmesbus_softc *hsc = (void *)self;
struct hme_softc *sc = &hsc->hsc_hme;
u_int32_t burst, sbusburst;
- int node;
- /* XXX the following declarations should be elsewhere */
+ /* XXX the following declaration should be elsewhere */
extern void myetheraddr(u_char *);
- node = sa->sa_node;
-
/* Pass on the bus tags */
sc->sc_bustag = sa->sa_bustag;
sc->sc_dmatag = sa->sa_dmatag;
+ if (sa->sa_nintr < 1) {
+ printf(": no interrupt\n");
+ return;
+ }
+
if (sa->sa_nreg < 5) {
- printf("%s: only %d register sets\n",
- self->dv_xname, sa->sa_nreg);
+ printf(": only %d register sets\n", sa->sa_nreg);
return;
}
@@ -122,31 +123,31 @@ hmeattach_sbus(struct device *parent, struct device *self, void *aux)
if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot,
(bus_addr_t)sa->sa_reg[0].sbr_offset,
(bus_size_t)sa->sa_reg[0].sbr_size, 0, 0, &sc->sc_seb) != 0) {
- printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[1].sbr_slot,
(bus_addr_t)sa->sa_reg[1].sbr_offset,
(bus_size_t)sa->sa_reg[1].sbr_size, 0, 0, &sc->sc_etx) != 0) {
- printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[2].sbr_slot,
(bus_addr_t)sa->sa_reg[2].sbr_offset,
(bus_size_t)sa->sa_reg[2].sbr_size, 0, 0, &sc->sc_erx) != 0) {
- printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[3].sbr_slot,
(bus_addr_t)sa->sa_reg[3].sbr_offset,
(bus_size_t)sa->sa_reg[3].sbr_size, 0, 0, &sc->sc_mac) != 0) {
- printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[4].sbr_slot,
(bus_addr_t)sa->sa_reg[4].sbr_offset,
(bus_size_t)sa->sa_reg[4].sbr_size, 0, 0, &sc->sc_mif) != 0) {
- printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+ printf(": can't map registers\n");
return;
}
@@ -162,7 +163,7 @@ hmeattach_sbus(struct device *parent, struct device *self, void *aux)
if (sbusburst == 0)
sbusburst = SBUS_BURST_32 - 1; /* 1->16 */
- burst = getpropint(node, "burst-sizes", -1);
+ burst = getpropint(sa->sa_node, "burst-sizes", -1);
if (burst == -1)
/* take SBus burst sizes */
burst = sbusburst;
@@ -183,9 +184,8 @@ hmeattach_sbus(struct device *parent, struct device *self, void *aux)
sc->sc_pci = 0; /* XXXXX should all be done in bus_dma. */
/* Establish interrupt handler */
- if (sa->sa_nintr != 0)
- (void)bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET, 0,
- hme_intr, sc, self->dv_xname);
+ bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET, 0, hme_intr,
+ sc, self->dv_xname);
hme_config(sc);
}