aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss/maestro3.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/oss/maestro3.c')
-rw-r--r--sound/oss/maestro3.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sound/oss/maestro3.c b/sound/oss/maestro3.c
index f3dec70fcb9b..66044aff2586 100644
--- a/sound/oss/maestro3.c
+++ b/sound/oss/maestro3.c
@@ -144,6 +144,8 @@
144#include <linux/spinlock.h> 144#include <linux/spinlock.h>
145#include <linux/ac97_codec.h> 145#include <linux/ac97_codec.h>
146#include <linux/wait.h> 146#include <linux/wait.h>
147#include <linux/mutex.h>
148
147 149
148#include <asm/io.h> 150#include <asm/io.h>
149#include <asm/dma.h> 151#include <asm/dma.h>
@@ -205,7 +207,7 @@ struct m3_state {
205 when irqhandler uses s->lock 207 when irqhandler uses s->lock
206 and m3_assp_read uses card->lock ? 208 and m3_assp_read uses card->lock ?
207 */ 209 */
208 struct semaphore open_sem; 210 struct mutex open_mutex;
209 wait_queue_head_t open_wait; 211 wait_queue_head_t open_wait;
210 mode_t open_mode; 212 mode_t open_mode;
211 213
@@ -2013,17 +2015,17 @@ static int m3_open(struct inode *inode, struct file *file)
2013 file->private_data = s; 2015 file->private_data = s;
2014 2016
2015 /* wait for device to become free */ 2017 /* wait for device to become free */
2016 down(&s->open_sem); 2018 mutex_lock(&s->open_mutex);
2017 while (s->open_mode & file->f_mode) { 2019 while (s->open_mode & file->f_mode) {
2018 if (file->f_flags & O_NONBLOCK) { 2020 if (file->f_flags & O_NONBLOCK) {
2019 up(&s->open_sem); 2021 mutex_unlock(&s->open_mutex);
2020 return -EWOULDBLOCK; 2022 return -EWOULDBLOCK;
2021 } 2023 }
2022 up(&s->open_sem); 2024 mutex_unlock(&s->open_mutex);
2023 interruptible_sleep_on(&s->open_wait); 2025 interruptible_sleep_on(&s->open_wait);
2024 if (signal_pending(current)) 2026 if (signal_pending(current))
2025 return -ERESTARTSYS; 2027 return -ERESTARTSYS;
2026 down(&s->open_sem); 2028 mutex_lock(&s->open_mutex);
2027 } 2029 }
2028 2030
2029 spin_lock_irqsave(&c->lock, flags); 2031 spin_lock_irqsave(&c->lock, flags);
@@ -2047,7 +2049,7 @@ static int m3_open(struct inode *inode, struct file *file)
2047 set_fmt(s, fmtm, fmts); 2049 set_fmt(s, fmtm, fmts);
2048 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2050 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2049 2051
2050 up(&s->open_sem); 2052 mutex_unlock(&s->open_mutex);
2051 spin_unlock_irqrestore(&c->lock, flags); 2053 spin_unlock_irqrestore(&c->lock, flags);
2052 return nonseekable_open(inode, file); 2054 return nonseekable_open(inode, file);
2053} 2055}
@@ -2062,7 +2064,7 @@ static int m3_release(struct inode *inode, struct file *file)
2062 if (file->f_mode & FMODE_WRITE) 2064 if (file->f_mode & FMODE_WRITE)
2063 drain_dac(s, file->f_flags & O_NONBLOCK); 2065 drain_dac(s, file->f_flags & O_NONBLOCK);
2064 2066
2065 down(&s->open_sem); 2067 mutex_lock(&s->open_mutex);
2066 spin_lock_irqsave(&card->lock, flags); 2068 spin_lock_irqsave(&card->lock, flags);
2067 2069
2068 if (file->f_mode & FMODE_WRITE) { 2070 if (file->f_mode & FMODE_WRITE) {
@@ -2083,7 +2085,7 @@ static int m3_release(struct inode *inode, struct file *file)
2083 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 2085 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
2084 2086
2085 spin_unlock_irqrestore(&card->lock, flags); 2087 spin_unlock_irqrestore(&card->lock, flags);
2086 up(&s->open_sem); 2088 mutex_unlock(&s->open_mutex);
2087 wake_up(&s->open_wait); 2089 wake_up(&s->open_wait);
2088 2090
2089 return 0; 2091 return 0;
@@ -2679,7 +2681,7 @@ static int __devinit m3_probe(struct pci_dev *pci_dev, const struct pci_device_i
2679 init_waitqueue_head(&s->dma_adc.wait); 2681 init_waitqueue_head(&s->dma_adc.wait);
2680 init_waitqueue_head(&s->dma_dac.wait); 2682 init_waitqueue_head(&s->dma_dac.wait);
2681 init_waitqueue_head(&s->open_wait); 2683 init_waitqueue_head(&s->open_wait);
2682 init_MUTEX(&(s->open_sem)); 2684 mutex_init(&(s->open_mutex));
2683 s->magic = M3_STATE_MAGIC; 2685 s->magic = M3_STATE_MAGIC;
2684 2686
2685 m3_assp_client_init(s); 2687 m3_assp_client_init(s);