[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>
diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c
index ff6da16..6fd60b7 100644
--- a/sound/drivers/opl3/opl3_seq.c
+++ b/sound/drivers/opl3/opl3_seq.c
@@ -51,14 +51,15 @@
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 @@
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)