Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108575540
D45857.id140507.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D45857.id140507.diff
View Options
diff --git a/sys/dev/sound/midi/midi.h b/sys/dev/sound/midi/midi.h
--- a/sys/dev/sound/midi/midi.h
+++ b/sys/dev/sound/midi/midi.h
@@ -39,8 +39,6 @@
#define M_RXEN 0x04
#define M_TXEN 0x08
-extern struct sx midistat_lock;
-
struct snd_midi;
struct snd_midi *
@@ -56,4 +54,8 @@
kobj_t midimapper_fetch_synth_locked(void *arg, void *cookie, int unit);
kobj_t midimapper_fetch_synth(void *arg, void *cookie, int unit);
+void midistat_lock(void);
+void midistat_unlock(void);
+void midistat_lockassert(void);
+
#endif
diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c
--- a/sys/dev/sound/midi/midi.c
+++ b/sys/dev/sound/midi/midi.c
@@ -177,7 +177,7 @@
* /dev/midistat variables and declarations, protected by midistat_lock
*/
-struct sx midistat_lock;
+struct sx mstat_lock;
static int midistat_isopen = 0;
static struct sbuf midistat_sbuf;
@@ -258,6 +258,24 @@
* CODE START
*/
+void
+midistat_lock(void)
+{
+ sx_xlock(&mstat_lock);
+}
+
+void
+midistat_unlock(void)
+{
+ sx_xunlock(&mstat_lock);
+}
+
+void
+midistat_lockassert(void)
+{
+ sx_assert(&mstat_lock, SA_XLOCKED);
+}
+
/*
* Register a new rmidi device. cls midi_if interface unit == 0 means
* auto-assign new unit number unit != 0 already assigned a unit number, eg.
@@ -280,7 +298,7 @@
uint8_t *buf;
MIDI_DEBUG(1, printf("midiinit: unit %d/%d.\n", unit, channel));
- sx_xlock(&midistat_lock);
+ midistat_lock();
/*
* Protect against call with existing unit/channel or auto-allocate a
* new unit number.
@@ -358,7 +376,7 @@
TAILQ_INSERT_TAIL(&midi_devs, m, link);
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
m->dev = make_dev(&midi_cdevsw, unit, UID_ROOT, GID_WHEEL, 0666,
"midi%d.%d", unit, channel);
@@ -378,7 +396,7 @@
free(m->synth, M_MIDI);
free(m, M_MIDI);
err0:
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
MIDI_DEBUG(1, printf("midi_init ended in error\n"));
return NULL;
}
@@ -396,7 +414,7 @@
int err;
err = EBUSY;
- sx_xlock(&midistat_lock);
+ midistat_lock();
mtx_lock(&m->lock);
if (m->busy) {
if (!(m->rchan || m->wchan))
@@ -418,7 +436,7 @@
err:
mtx_unlock(&m->lock);
exit:
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return err;
}
@@ -926,9 +944,9 @@
MIDI_DEBUG(1, printf("midistat_open\n"));
- sx_xlock(&midistat_lock);
+ midistat_lock();
if (midistat_isopen) {
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return EBUSY;
}
midistat_isopen = 1;
@@ -940,7 +958,7 @@
out:
if (error)
midistat_isopen = 0;
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return error;
}
@@ -948,14 +966,14 @@
midistat_close(struct cdev *i_dev, int flags, int mode, struct thread *td)
{
MIDI_DEBUG(1, printf("midistat_close\n"));
- sx_xlock(&midistat_lock);
+ midistat_lock();
if (!midistat_isopen) {
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return EBADF;
}
sbuf_delete(&midistat_sbuf);
midistat_isopen = 0;
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return 0;
}
@@ -966,13 +984,13 @@
int err;
MIDI_DEBUG(4, printf("midistat_read\n"));
- sx_xlock(&midistat_lock);
+ midistat_lock();
if (!midistat_isopen) {
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return EBADF;
}
if (uio->uio_offset < 0 || uio->uio_offset > sbuf_len(&midistat_sbuf)) {
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return EINVAL;
}
err = 0;
@@ -981,7 +999,7 @@
err = uiomove(sbuf_data(&midistat_sbuf) + uio->uio_offset, l,
uio);
}
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return err;
}
@@ -994,7 +1012,7 @@
{
struct snd_midi *m;
- sx_assert(&midistat_lock, SA_XLOCKED);
+ midistat_lockassert();
sbuf_printf(s, "FreeBSD Midi Driver (midi2)\n");
if (TAILQ_EMPTY(&midi_devs)) {
@@ -1353,7 +1371,7 @@
static int
midi_destroy(struct snd_midi *m, int midiuninit)
{
- sx_assert(&midistat_lock, SA_XLOCKED);
+ midistat_lockassert();
mtx_assert(&m->lock, MA_OWNED);
MIDI_DEBUG(3, printf("midi_destroy\n"));
@@ -1379,7 +1397,7 @@
static int
midi_load(void)
{
- sx_init(&midistat_lock, "midistat lock");
+ sx_init(&mstat_lock, "midistat lock");
TAILQ_INIT(&midi_devs);
midistat_dev = make_dev(&midistat_cdevsw, MIDI_DEV_MIDICTL, UID_ROOT,
@@ -1396,7 +1414,7 @@
MIDI_DEBUG(1, printf("midi_unload()\n"));
retval = EBUSY;
- sx_xlock(&midistat_lock);
+ midistat_lock();
if (midistat_isopen)
goto exit0;
@@ -1409,19 +1427,19 @@
if (retval)
goto exit1;
}
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
destroy_dev(midistat_dev);
/*
* Made it here then unload is complete
*/
- sx_destroy(&midistat_lock);
+ sx_destroy(&mstat_lock);
return 0;
exit1:
mtx_unlock(&m->lock);
exit0:
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
if (retval)
MIDI_DEBUG(2, printf("midi_unload: failed\n"));
return retval;
@@ -1470,7 +1488,7 @@
int retval = 0;
struct snd_midi *m;
- sx_assert(&midistat_lock, SX_XLOCKED);
+ midistat_lockassert();
TAILQ_FOREACH(m, &midi_devs, link) {
retval++;
}
@@ -1483,9 +1501,9 @@
{
int retval;
- sx_xlock(&midistat_lock);
+ midistat_lock();
retval = midimapper_open_locked(arg1, cookie);
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return retval;
}
@@ -1502,7 +1520,7 @@
struct snd_midi *m;
int retval = 0;
- sx_assert(&midistat_lock, SX_XLOCKED);
+ midistat_lockassert();
TAILQ_FOREACH(m, &midi_devs, link) {
if (unit == retval)
return (kobj_t)m->synth;
@@ -1517,9 +1535,9 @@
{
kobj_t synth;
- sx_xlock(&midistat_lock);
+ midistat_lock();
synth = midimapper_fetch_synth_locked(arg, cookie, unit);
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
return synth;
}
diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c
--- a/sys/dev/sound/midi/sequencer.c
+++ b/sys/dev/sound/midi/sequencer.c
@@ -746,7 +746,7 @@
* Mark this device busy.
*/
- sx_xlock(&midistat_lock);
+ midistat_lock();
mtx_lock(&scp->seq_lock);
if (scp->busy) {
mtx_unlock(&scp->seq_lock);
@@ -784,7 +784,7 @@
}
}
}
- sx_xunlock(&midistat_lock);
+ midistat_unlock();
timer_setvals(scp, 60, 100);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 12:59 PM (40 m, 44 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16197008
Default Alt Text
D45857.id140507.diff (6 KB)
Attached To
Mode
D45857: sound: Handle midistat_lock through function interface
Attached
Detach File
Event Timeline
Log In to Comment