aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss/au1550_ac97.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/oss/au1550_ac97.c')
-rw-r--r--sound/oss/au1550_ac97.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index bdee0502f3e2..6a4956b8025d 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -52,6 +52,8 @@
52#include <linux/spinlock.h> 52#include <linux/spinlock.h>
53#include <linux/smp_lock.h> 53#include <linux/smp_lock.h>
54#include <linux/ac97_codec.h> 54#include <linux/ac97_codec.h>
55#include <linux/mutex.h>
56
55#include <asm/io.h> 57#include <asm/io.h>
56#include <asm/uaccess.h> 58#include <asm/uaccess.h>
57#include <asm/hardirq.h> 59#include <asm/hardirq.h>
@@ -90,8 +92,8 @@ static struct au1550_state {
90 int no_vra; /* do not use VRA */ 92 int no_vra; /* do not use VRA */
91 93
92 spinlock_t lock; 94 spinlock_t lock;
93 struct semaphore open_sem; 95 struct mutex open_mutex;
94 struct semaphore sem; 96 struct mutex sem;
95 mode_t open_mode; 97 mode_t open_mode;
96 wait_queue_head_t open_wait; 98 wait_queue_head_t open_wait;
97 99
@@ -1044,7 +1046,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
1044 1046
1045 count *= db->cnt_factor; 1047 count *= db->cnt_factor;
1046 1048
1047 down(&s->sem); 1049 mutex_lock(&s->sem);
1048 add_wait_queue(&db->wait, &wait); 1050 add_wait_queue(&db->wait, &wait);
1049 1051
1050 while (count > 0) { 1052 while (count > 0) {
@@ -1064,14 +1066,14 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
1064 ret = -EAGAIN; 1066 ret = -EAGAIN;
1065 goto out; 1067 goto out;
1066 } 1068 }
1067 up(&s->sem); 1069 mutex_unlock(&s->sem);
1068 schedule(); 1070 schedule();
1069 if (signal_pending(current)) { 1071 if (signal_pending(current)) {
1070 if (!ret) 1072 if (!ret)
1071 ret = -ERESTARTSYS; 1073 ret = -ERESTARTSYS;
1072 goto out2; 1074 goto out2;
1073 } 1075 }
1074 down(&s->sem); 1076 mutex_lock(&s->sem);
1075 } 1077 }
1076 } while (avail <= 0); 1078 } while (avail <= 0);
1077 1079
@@ -1099,7 +1101,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
1099 } /* while (count > 0) */ 1101 } /* while (count > 0) */
1100 1102
1101out: 1103out:
1102 up(&s->sem); 1104 mutex_unlock(&s->sem);
1103out2: 1105out2:
1104 remove_wait_queue(&db->wait, &wait); 1106 remove_wait_queue(&db->wait, &wait);
1105 set_current_state(TASK_RUNNING); 1107 set_current_state(TASK_RUNNING);
@@ -1125,7 +1127,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
1125 1127
1126 count *= db->cnt_factor; 1128 count *= db->cnt_factor;
1127 1129
1128 down(&s->sem); 1130 mutex_lock(&s->sem);
1129 add_wait_queue(&db->wait, &wait); 1131 add_wait_queue(&db->wait, &wait);
1130 1132
1131 while (count > 0) { 1133 while (count > 0) {
@@ -1143,14 +1145,14 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
1143 ret = -EAGAIN; 1145 ret = -EAGAIN;
1144 goto out; 1146 goto out;
1145 } 1147 }
1146 up(&s->sem); 1148 mutex_unlock(&s->sem);
1147 schedule(); 1149 schedule();
1148 if (signal_pending(current)) { 1150 if (signal_pending(current)) {
1149 if (!ret) 1151 if (!ret)
1150 ret = -ERESTARTSYS; 1152 ret = -ERESTARTSYS;
1151 goto out2; 1153 goto out2;
1152 } 1154 }
1153 down(&s->sem); 1155 mutex_lock(&s->sem);
1154 } 1156 }
1155 } while (avail <= 0); 1157 } while (avail <= 0);
1156 1158
@@ -1196,7 +1198,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
1196 } /* while (count > 0) */ 1198 } /* while (count > 0) */
1197 1199
1198out: 1200out:
1199 up(&s->sem); 1201 mutex_unlock(&s->sem);
1200out2: 1202out2:
1201 remove_wait_queue(&db->wait, &wait); 1203 remove_wait_queue(&db->wait, &wait);
1202 set_current_state(TASK_RUNNING); 1204 set_current_state(TASK_RUNNING);
@@ -1253,7 +1255,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
1253 int ret = 0; 1255 int ret = 0;
1254 1256
1255 lock_kernel(); 1257 lock_kernel();
1256 down(&s->sem); 1258 mutex_lock(&s->sem);
1257 if (vma->vm_flags & VM_WRITE) 1259 if (vma->vm_flags & VM_WRITE)
1258 db = &s->dma_dac; 1260 db = &s->dma_dac;
1259 else if (vma->vm_flags & VM_READ) 1261 else if (vma->vm_flags & VM_READ)
@@ -1279,7 +1281,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
1279 vma->vm_flags &= ~VM_IO; 1281 vma->vm_flags &= ~VM_IO;
1280 db->mapped = 1; 1282 db->mapped = 1;
1281out: 1283out:
1282 up(&s->sem); 1284 mutex_unlock(&s->sem);
1283 unlock_kernel(); 1285 unlock_kernel();
1284 return ret; 1286 return ret;
1285} 1287}
@@ -1790,21 +1792,21 @@ au1550_open(struct inode *inode, struct file *file)
1790 1792
1791 file->private_data = s; 1793 file->private_data = s;
1792 /* wait for device to become free */ 1794 /* wait for device to become free */
1793 down(&s->open_sem); 1795 mutex_lock(&s->open_mutex);
1794 while (s->open_mode & file->f_mode) { 1796 while (s->open_mode & file->f_mode) {
1795 if (file->f_flags & O_NONBLOCK) { 1797 if (file->f_flags & O_NONBLOCK) {
1796 up(&s->open_sem); 1798 mutex_unlock(&s->open_mutex);
1797 return -EBUSY; 1799 return -EBUSY;
1798 } 1800 }
1799 add_wait_queue(&s->open_wait, &wait); 1801 add_wait_queue(&s->open_wait, &wait);
1800 __set_current_state(TASK_INTERRUPTIBLE); 1802 __set_current_state(TASK_INTERRUPTIBLE);
1801 up(&s->open_sem); 1803 mutex_unlock(&s->open_mutex);
1802 schedule(); 1804 schedule();
1803 remove_wait_queue(&s->open_wait, &wait); 1805 remove_wait_queue(&s->open_wait, &wait);
1804 set_current_state(TASK_RUNNING); 1806 set_current_state(TASK_RUNNING);
1805 if (signal_pending(current)) 1807 if (signal_pending(current))
1806 return -ERESTARTSYS; 1808 return -ERESTARTSYS;
1807 down(&s->open_sem); 1809 mutex_lock(&s->open_mutex);
1808 } 1810 }
1809 1811
1810 stop_dac(s); 1812 stop_dac(s);
@@ -1840,8 +1842,8 @@ au1550_open(struct inode *inode, struct file *file)
1840 } 1842 }
1841 1843
1842 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1844 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1843 up(&s->open_sem); 1845 mutex_unlock(&s->open_mutex);
1844 init_MUTEX(&s->sem); 1846 mutex_init(&s->sem);
1845 return 0; 1847 return 0;
1846} 1848}
1847 1849
@@ -1858,7 +1860,7 @@ au1550_release(struct inode *inode, struct file *file)
1858 lock_kernel(); 1860 lock_kernel();
1859 } 1861 }
1860 1862
1861 down(&s->open_sem); 1863 mutex_lock(&s->open_mutex);
1862 if (file->f_mode & FMODE_WRITE) { 1864 if (file->f_mode & FMODE_WRITE) {
1863 stop_dac(s); 1865 stop_dac(s);
1864 kfree(s->dma_dac.rawbuf); 1866 kfree(s->dma_dac.rawbuf);
@@ -1870,7 +1872,7 @@ au1550_release(struct inode *inode, struct file *file)
1870 s->dma_adc.rawbuf = NULL; 1872 s->dma_adc.rawbuf = NULL;
1871 } 1873 }
1872 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); 1874 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
1873 up(&s->open_sem); 1875 mutex_unlock(&s->open_mutex);
1874 wake_up(&s->open_wait); 1876 wake_up(&s->open_wait);
1875 unlock_kernel(); 1877 unlock_kernel();
1876 return 0; 1878 return 0;
@@ -1902,7 +1904,7 @@ au1550_probe(void)
1902 init_waitqueue_head(&s->dma_adc.wait); 1904 init_waitqueue_head(&s->dma_adc.wait);
1903 init_waitqueue_head(&s->dma_dac.wait); 1905 init_waitqueue_head(&s->dma_dac.wait);
1904 init_waitqueue_head(&s->open_wait); 1906 init_waitqueue_head(&s->open_wait);
1905 init_MUTEX(&s->open_sem); 1907 mutex_init(&s->open_mutex);
1906 spin_lock_init(&s->lock); 1908 spin_lock_init(&s->lock);
1907 1909
1908 s->codec = ac97_alloc_codec(); 1910 s->codec = ac97_alloc_codec();