diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-10-30 13:59:15 +0300 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 19:29:13 +0300 |
commit | 05c1afe75fcebf456017ec186811cf1599f4360e (patch) | |
tree | 3000085048bb79d54f61c993c2b8e5eb1bd0618f /sound/drivers/opl3 | |
parent | 224a033252bba46c5c8b5df625f5e781ca138f48 (diff) | |
download | linux-05c1afe75fcebf456017ec186811cf1599f4360e.tar.xz |
[ALSA] opl3 - simplify exclusive access lock
Use the exclusive access lock in hwdep instead of the own one.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/drivers/opl3')
-rw-r--r-- | sound/drivers/opl3/opl3_lib.c | 2 | ||||
-rw-r--r-- | sound/drivers/opl3/opl3_seq.c | 19 | ||||
-rw-r--r-- | sound/drivers/opl3/opl3_synth.c | 14 |
3 files changed, 12 insertions, 23 deletions
diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index a657da922b4d..a1270841290b 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -361,7 +361,6 @@ int snd_opl3_new(struct snd_card *card, opl3->hardware = hardware; spin_lock_init(&opl3->reg_lock); spin_lock_init(&opl3->timer_lock); - mutex_init(&opl3->access_mutex); if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) { snd_opl3_free(opl3); @@ -497,6 +496,7 @@ int snd_opl3_hwdep_new(struct snd_opl3 * opl3, return err; } hw->private_data = opl3; + hw->exclusive = 1; #ifdef CONFIG_SND_OSSEMUL if (device == 0) { hw->oss_type = SNDRV_OSS_DEVICE_TYPE_DMFM; diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index ff6da16b9178..6fd60b7e5805 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -51,14 +51,15 @@ void snd_opl3_synth_use_dec(struct snd_opl3 * opl3) int snd_opl3_synth_setup(struct snd_opl3 * opl3) { int idx; + struct snd_hwdep *hwdep = opl3->hwdep; - mutex_lock(&opl3->access_mutex); - if (opl3->used) { - mutex_unlock(&opl3->access_mutex); + mutex_lock(&hwdep->open_mutex); + if (hwdep->used) { + mutex_unlock(&hwdep->open_mutex); return -EBUSY; } - opl3->used++; - mutex_unlock(&opl3->access_mutex); + hwdep->used++; + mutex_unlock(&hwdep->open_mutex); snd_opl3_reset(opl3); @@ -91,9 +92,11 @@ void snd_opl3_synth_cleanup(struct snd_opl3 * opl3) spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); snd_opl3_reset(opl3); - mutex_lock(&opl3->access_mutex); - opl3->used--; - mutex_unlock(&opl3->access_mutex); + hwdep = opl3->hwdep; + mutex_lock(&hwdep->open_mutex); + hwdep->used--; + mutex_unlock(&hwdep->open_mutex); + wake_up(&hwdep->open_wait); } static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info) diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c index d55eefce44c1..a7bf7a4b1f85 100644 --- a/sound/drivers/opl3/opl3_synth.c +++ b/sound/drivers/opl3/opl3_synth.c @@ -76,16 +76,6 @@ static int snd_opl3_set_connection(struct snd_opl3 * opl3, int connection); */ int snd_opl3_open(struct snd_hwdep * hw, struct file *file) { - struct snd_opl3 *opl3 = hw->private_data; - - mutex_lock(&opl3->access_mutex); - if (opl3->used) { - mutex_unlock(&opl3->access_mutex); - return -EAGAIN; - } - opl3->used++; - mutex_unlock(&opl3->access_mutex); - return 0; } @@ -185,10 +175,6 @@ int snd_opl3_release(struct snd_hwdep * hw, struct file *file) struct snd_opl3 *opl3 = hw->private_data; snd_opl3_reset(opl3); - mutex_lock(&opl3->access_mutex); - opl3->used--; - mutex_unlock(&opl3->access_mutex); - return 0; } |