diff options
author | cg <cg@FreeBSD.org> | 2001-06-23 17:36:51 +0000 |
---|---|---|
committer | cg <cg@FreeBSD.org> | 2001-06-23 17:36:51 +0000 |
commit | f4d67f070515aea9b806739c31a68a83a74664a3 (patch) | |
tree | f4eb53502dd9da5cf589d2fef965f6d9a6c863dc /sys/dev/sound/pcm/sndstat.c | |
parent | 601ee32495961d995a6be39f850536c07504bc40 (diff) | |
download | FreeBSD-src-f4d67f070515aea9b806739c31a68a83a74664a3.zip FreeBSD-src-f4d67f070515aea9b806739c31a68a83a74664a3.tar.gz |
add defines and ifdefs so this code will compile on 4.x
add spls so this code will work on 4.x
Diffstat (limited to 'sys/dev/sound/pcm/sndstat.c')
-rw-r--r-- | sys/dev/sound/pcm/sndstat.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index a16c07e..6792700 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -58,7 +58,11 @@ static int sndstat_isopen = 0; static int sndstat_bufptr; static int sndstat_verbose = 0; +#ifdef USING_MUTEX TUNABLE_INT("hw.snd.verbose", &sndstat_verbose); +#else +TUNABLE_INT_DECL("hw.snd.verbose", 0, sndstat_verbose); +#endif static int sndstat_prepare(struct sbuf *s); @@ -83,42 +87,60 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, verbose, CTLTYPE_INT | CTLFLAG_RW, static int sndstat_open(dev_t i_dev, int flags, int mode, struct proc *p) { + intrmask_t s; int err; - if (sndstat_isopen) + s = spltty(); + if (sndstat_isopen) { + splx(s); return EBUSY; - if (sbuf_new(&sndstat_sbuf, NULL, 4096, 0) == NULL) + } + if (sbuf_new(&sndstat_sbuf, NULL, 4096, 0) == NULL) { + splx(s); return ENXIO; + } sndstat_bufptr = 0; err = (sndstat_prepare(&sndstat_sbuf) > 0)? 0 : ENOMEM; if (!err) sndstat_isopen = 1; + splx(s); return err; } static int sndstat_close(dev_t i_dev, int flags, int mode, struct proc *p) { - if (!sndstat_isopen) + intrmask_t s; + + s = spltty(); + if (!sndstat_isopen) { + splx(s); return EBADF; + } sbuf_delete(&sndstat_sbuf); sndstat_isopen = 0; + splx(s); return 0; } static int sndstat_read(dev_t i_dev, struct uio *buf, int flag) { + intrmask_t s; int l, err; - if (!sndstat_isopen) + s = spltty(); + if (!sndstat_isopen) { + splx(s); return EBADF; + } l = min(buf->uio_resid, sbuf_len(&sndstat_sbuf) - sndstat_bufptr); err = (l > 0)? uiomove(sbuf_data(&sndstat_sbuf) + sndstat_bufptr, l, buf) : 0; sndstat_bufptr += l; + splx(s); return err; } @@ -212,13 +234,19 @@ sndstat_init(void) static int sndstat_uninit(void) { - if (sndstat_isopen) + intrmask_t s; + + s = spltty(); + if (sndstat_isopen) { + splx(s); return EBUSY; + } if (sndstat_dev) destroy_dev(sndstat_dev); sndstat_dev = 0; + splx(s); return 0; } |