summaryrefslogtreecommitdiff
path: root/sys/arch/sgi/dev
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-05-20 14:17:06 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-05-20 14:17:06 +0000
commitf6a0eb61b4b720f21c8815f57ed6b03cb03f6238 (patch)
treecf72335be4e48a546327f815e76b001e56608658 /sys/arch/sgi/dev
parent465a7954565ab67f60d94ff8a1ab64233cdd441b (diff)
Check for codec presence in match(), and don't attach if none is found.
ok kettenis@
Diffstat (limited to 'sys/arch/sgi/dev')
-rw-r--r--sys/arch/sgi/dev/mavb.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/arch/sgi/dev/mavb.c b/sys/arch/sgi/dev/mavb.c
index c786d3a9131..cbc17bf0731 100644
--- a/sys/arch/sgi/dev/mavb.c
+++ b/sys/arch/sgi/dev/mavb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mavb.c,v 1.6 2005/04/15 13:05:14 mickey Exp $ */
+/* $OpenBSD: mavb.c,v 1.7 2007/05/20 14:17:05 miod Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -1062,11 +1062,19 @@ int
mavb_match(struct device *parent, void *match, void *aux)
{
struct confargs *ca = aux;
+ bus_space_handle_t ioh;
+ u_int64_t control;
if (ca->ca_sys != SGI_O2 || strcmp(ca->ca_name, mavb_cd.cd_name))
return (0);
- return (1);
+ if (bus_space_map(ca->ca_iot, ca->ca_baseaddr, MAVB_NREGS, 0,
+ &ioh) != 0)
+ return (0);
+ control = bus_space_read_8(ca->ca_iot, ioh, MAVB_CONTROL);
+ bus_space_unmap(ca->ca_iot, ioh, MAVB_NREGS);
+
+ return ((control & MAVB_CONTROL_CODEC_PRESENT) != 0);
}
void
@@ -1075,7 +1083,6 @@ mavb_attach(struct device *parent, struct device *self, void *aux)
struct mavb_softc *sc = (void *)self;
struct confargs *ca = aux;
bus_dma_segment_t seg;
- u_int64_t control;
u_int16_t value;
int rseg;
@@ -1126,12 +1133,6 @@ mavb_attach(struct device *parent, struct device *self, void *aux)
BUS_INTR_ESTABLISH(ca, NULL, ca->ca_intr, IST_EDGE, IPL_AUDIO,
mavb_intr, sc, sc->sc_dev.dv_xname);
- control = bus_space_read_8(sc->sc_st, sc->sc_sh, MAVB_CONTROL);
- if (!(control & MAVB_CONTROL_CODEC_PRESENT)) {
- printf(": no codec present\n");
- return;
- }
-
/* 2. Assert the RESET signal. */
bus_space_write_8(sc->sc_st, sc->sc_sh, MAVB_CONTROL,
MAVB_CONTROL_RESET);