Sat Jan 21 16:49:26 2012 UTC ()
src/sys/dev/ic/mpu.c
fix assertions after audiomp.


(chs)
diff -r1.18 -r1.19 src/sys/dev/ic/mpu.c

cvs diff -r1.18 -r1.19 src/sys/dev/ic/mpu.c (expand / switch to unified diff)

--- src/sys/dev/ic/mpu.c 2011/11/23 23:07:32 1.18
+++ src/sys/dev/ic/mpu.c 2012/01/21 16:49:26 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mpu.c,v 1.18 2011/11/23 23:07:32 jmcneill Exp $ */ 1/* $NetBSD: mpu.c,v 1.19 2012/01/21 16:49:26 chs Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (augustss@NetBSD.org) and by Andrew Doran. 8 * by Lennart Augustsson (augustss@NetBSD.org) and by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: mpu.c,v 1.18 2011/11/23 23:07:32 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: mpu.c,v 1.19 2012/01/21 16:49:26 chs Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/errno.h> 37#include <sys/errno.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/syslog.h> 39#include <sys/syslog.h>
40#include <sys/device.h> 40#include <sys/device.h>
41#include <sys/proc.h> 41#include <sys/proc.h>
42#include <sys/buf.h> 42#include <sys/buf.h>
43 43
44#include <sys/cpu.h> 44#include <sys/cpu.h>
45#include <sys/intr.h> 45#include <sys/intr.h>
46#include <sys/bus.h> 46#include <sys/bus.h>
@@ -113,51 +113,51 @@ mpu_attach(struct mpu_softc *sc) @@ -113,51 +113,51 @@ mpu_attach(struct mpu_softc *sc)
113 113
114 if (sc->lock == NULL) { 114 if (sc->lock == NULL) {
115 panic("mpu_attach: no lock"); 115 panic("mpu_attach: no lock");
116 } 116 }
117 117
118 midi_attach_mi(&mpu_midi_hw_if, sc, sc->sc_dev); 118 midi_attach_mi(&mpu_midi_hw_if, sc, sc->sc_dev);
119} 119}
120 120
121static inline int 121static inline int
122mpu_waitready(struct mpu_softc *sc) 122mpu_waitready(struct mpu_softc *sc)
123{ 123{
124 int i; 124 int i;
125 125
126 KASSERT(mutex_owned(sc->lock)); 126 KASSERT(sc->lock == NULL || mutex_owned(sc->lock));
127 127
128 for(i = 0; i < MPU_MAXWAIT; i++) { 128 for (i = 0; i < MPU_MAXWAIT; i++) {
129 if (!(MPU_GETSTATUS(sc->iot, sc->ioh) & MPU_OUTPUT_BUSY)) 129 if (!(MPU_GETSTATUS(sc->iot, sc->ioh) & MPU_OUTPUT_BUSY))
130 return 0; 130 return 0;
131 delay(10); 131 delay(10);
132 } 132 }
133 return 1; 133 return 1;
134} 134}
135 135
136static int 136static int
137mpu_reset(struct mpu_softc *sc) 137mpu_reset(struct mpu_softc *sc)
138{ 138{
139 bus_space_tag_t iot = sc->iot; 139 bus_space_tag_t iot = sc->iot;
140 bus_space_handle_t ioh = sc->ioh; 140 bus_space_handle_t ioh = sc->ioh;
141 int i; 141 int i;
142 142
143 KASSERT(mutex_owned(sc->lock)); 143 KASSERT(sc->lock == NULL || mutex_owned(sc->lock));
144 144
145 if (mpu_waitready(sc)) { 145 if (mpu_waitready(sc)) {
146 DPRINTF(("%s: not ready\n", __func__)); 146 DPRINTF(("%s: not ready\n", __func__));
147 return EIO; 147 return EIO;
148 } 148 }
149 bus_space_write_1(iot, ioh, MPU_COMMAND, MPU_RESET); 149 bus_space_write_1(iot, ioh, MPU_COMMAND, MPU_RESET);
150 for(i = 0; i < 2*MPU_MAXWAIT; i++) { 150 for (i = 0; i < 2*MPU_MAXWAIT; i++) {
151 if (!(MPU_GETSTATUS(iot, ioh) & MPU_INPUT_EMPTY) && 151 if (!(MPU_GETSTATUS(iot, ioh) & MPU_INPUT_EMPTY) &&
152 bus_space_read_1(iot, ioh, MPU_DATA) == MPU_ACK) { 152 bus_space_read_1(iot, ioh, MPU_DATA) == MPU_ACK) {
153 return 0; 153 return 0;
154 } 154 }
155 } 155 }
156 DPRINTF(("%s: No ACK\n", __func__)); 156 DPRINTF(("%s: No ACK\n", __func__));
157 return EIO; 157 return EIO;
158} 158}
159 159
160static int 160static int
161mpu_open(void *addr, int flags, void (*iintr)(void *, int), 161mpu_open(void *addr, int flags, void (*iintr)(void *, int),
162 void (*ointr)(void *), void *arg) 162 void (*ointr)(void *), void *arg)
163{ 163{