aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-10-30 06:59:15 -0400
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:13 -0500
commit05c1afe75fcebf456017ec186811cf1599f4360e (patch)
tree3000085048bb79d54f61c993c2b8e5eb1bd0618f /sound/drivers
parent224a033252bba46c5c8b5df625f5e781ca138f48 (diff)
[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')
-rw-r--r--sound/drivers/opl3/opl3_lib.c2
-rw-r--r--sound/drivers/opl3/opl3_seq.c19
-rw-r--r--sound/drivers/opl3/opl3_synth.c14
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,
361 opl3->hardware = hardware; 361 opl3->hardware = hardware;
362 spin_lock_init(&opl3->reg_lock); 362 spin_lock_init(&opl3->reg_lock);
363 spin_lock_init(&opl3->timer_lock); 363 spin_lock_init(&opl3->timer_lock);
364 mutex_init(&opl3->access_mutex);
365 364
366 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) { 365 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) {
367 snd_opl3_free(opl3); 366 snd_opl3_free(opl3);
@@ -497,6 +496,7 @@ int snd_opl3_hwdep_new(struct snd_opl3 * opl3,
497 return err; 496 return err;
498 } 497 }
499 hw->private_data = opl3; 498 hw->private_data = opl3;
499 hw->exclusive = 1;
500#ifdef CONFIG_SND_OSSEMUL 500#ifdef CONFIG_SND_OSSEMUL
501 if (device == 0) { 501 if (device == 0) {
502 hw->oss_type = SNDRV_OSS_DEVICE_TYPE_DMFM; 502 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)
51int snd_opl3_synth_setup(struct snd_opl3 * opl3) 51int snd_opl3_synth_setup(struct snd_opl3 * opl3)
52{ 52{
53 int idx; 53 int idx;
54 struct snd_hwdep *hwdep = opl3->hwdep;
54 55
55 mutex_lock(&opl3->access_mutex); 56 mutex_lock(&hwdep->open_mutex);
56 if (opl3->used) { 57 if (hwdep->used) {
57 mutex_unlock(&opl3->access_mutex); 58 mutex_unlock(&hwdep->open_mutex);
58 return -EBUSY; 59 return -EBUSY;
59 } 60 }
60 opl3->used++; 61 hwdep->used++;
61 mutex_unlock(&opl3->access_mutex); 62 mutex_unlock(&hwdep->open_mutex);
62 63
63 snd_opl3_reset(opl3); 64 snd_opl3_reset(opl3);
64 65
@@ -91,9 +92,11 @@ void snd_opl3_synth_cleanup(struct snd_opl3 * opl3)
91 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); 92 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
92 93
93 snd_opl3_reset(opl3); 94 snd_opl3_reset(opl3);
94 mutex_lock(&opl3->access_mutex); 95 hwdep = opl3->hwdep;
95 opl3->used--; 96 mutex_lock(&hwdep->open_mutex);
96 mutex_unlock(&opl3->access_mutex); 97 hwdep->used--;
98 mutex_unlock(&hwdep->open_mutex);
99 wake_up(&hwdep->open_wait);
97} 100}
98 101
99static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info) 102static 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);
76 */ 76 */
77int snd_opl3_open(struct snd_hwdep * hw, struct file *file) 77int snd_opl3_open(struct snd_hwdep * hw, struct file *file)
78{ 78{
79 struct snd_opl3 *opl3 = hw->private_data;
80
81 mutex_lock(&opl3->access_mutex);
82 if (opl3->used) {
83 mutex_unlock(&opl3->access_mutex);
84 return -EAGAIN;
85 }
86 opl3->used++;
87 mutex_unlock(&opl3->access_mutex);
88
89 return 0; 79 return 0;
90} 80}
91 81
@@ -185,10 +175,6 @@ int snd_opl3_release(struct snd_hwdep * hw, struct file *file)
185 struct snd_opl3 *opl3 = hw->private_data; 175 struct snd_opl3 *opl3 = hw->private_data;
186 176
187 snd_opl3_reset(opl3); 177 snd_opl3_reset(opl3);
188 mutex_lock(&opl3->access_mutex);
189 opl3->used--;
190 mutex_unlock(&opl3->access_mutex);
191
192 return 0; 178 return 0;
193} 179}
194 180