diff options
author | tanimura <tanimura@FreeBSD.org> | 2001-05-08 12:15:26 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2001-05-08 12:15:26 +0000 |
commit | 0f839f42de83439aea21cd10c66075e54df7e35b (patch) | |
tree | 6b9d571003bc6954f0c297abbc04a4ffd0ef33ba /sys | |
parent | ebaec1dfe06f27da691611d6a198f5289db92d0c (diff) | |
download | FreeBSD-src-0f839f42de83439aea21cd10c66075e54df7e35b.zip FreeBSD-src-0f839f42de83439aea21cd10c66075e54df7e35b.tar.gz |
- Eliminate locks in functions called only during probe and attach.
- Finish transmitting data to mpu when a buffer gets empty.
Submitted by: KUROSAWA Takahiro <fwkg7679@mb.infoweb.ne.jp>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/sound/isa/mpu.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/dev/sound/isa/mpu.c b/sys/dev/sound/isa/mpu.c index 0799da5..e865873 100644 --- a/sys/dev/sound/isa/mpu.c +++ b/sys/dev/sound/isa/mpu.c @@ -567,7 +567,9 @@ mpu_xmit(sc_p scp) /* Transmit the data in the queue. */ while ((devinfo->flags & MIDI_F_WRITING) != 0) { - if (dbuf->rl > 0) { + if (dbuf->rl == 0) + break; + else { mtx_lock(&scp->mtx); /* XXX Wait until we can write the data. */ if ((mpu_status(scp) & MPU_OUTPUTBUSY) == 0) { @@ -585,7 +587,10 @@ mpu_xmit(sc_p scp) } -/* Reset mpu. */ +/* + * Reset mpu. + * The caller must lock scp->mtx before calling this function if needed. + */ static int mpu_resetmode(sc_p scp) { @@ -593,13 +598,11 @@ mpu_resetmode(sc_p scp) /* Reset the mpu. */ resp = 0; - mtx_lock(&scp->mtx); for (i = 0 ; i < MPU_TRYDATA ; i++) { resp = mpu_command(scp, MPU_RESET); if (resp == 0) break; } - mtx_unlock(&scp->mtx); if (resp != 0) return (1); @@ -607,7 +610,10 @@ mpu_resetmode(sc_p scp) return (0); } -/* Switch to uart mode. */ +/* + * Switch to uart mode. + * The caller must lock scp->mtx before calling this function if needed. + */ static int mpu_uartmode(sc_p scp) { @@ -615,13 +621,11 @@ mpu_uartmode(sc_p scp) /* Switch to uart mode. */ resp = 0; - mtx_lock(&scp->mtx); for (i = 0 ; i < MPU_TRYDATA ; i++) { resp = mpu_command(scp, MPU_UART); if (resp == 0) break; } - mtx_unlock(&scp->mtx); if (resp != 0) return (1); @@ -629,20 +633,21 @@ mpu_uartmode(sc_p scp) return (0); } -/* Wait to see an ACK. */ +/* + * Wait to see an ACK. + * The caller must lock scp->mtx before calling this function if needed. + */ static int mpu_waitack(sc_p scp) { int i, resp; resp = 0; - mtx_lock(&scp->mtx); for (i = 0 ; i < MPU_TRYDATA ; i++) { resp = mpu_readdata(scp); if (resp >= 0) break; } - mtx_unlock(&scp->mtx); if (resp != MPU_ACK) return (1); |