diff options
Diffstat (limited to 'sound/oss/au1000.c')
| -rw-r--r-- | sound/oss/au1000.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sound/oss/au1000.c b/sound/oss/au1000.c index c407de86cbb6..fe54de25aafc 100644 --- a/sound/oss/au1000.c +++ b/sound/oss/au1000.c | |||
| @@ -68,6 +68,8 @@ | |||
| 68 | #include <linux/smp_lock.h> | 68 | #include <linux/smp_lock.h> |
| 69 | #include <linux/ac97_codec.h> | 69 | #include <linux/ac97_codec.h> |
| 70 | #include <linux/interrupt.h> | 70 | #include <linux/interrupt.h> |
| 71 | #include <linux/mutex.h> | ||
| 72 | |||
| 71 | #include <asm/io.h> | 73 | #include <asm/io.h> |
| 72 | #include <asm/uaccess.h> | 74 | #include <asm/uaccess.h> |
| 73 | #include <asm/mach-au1x00/au1000.h> | 75 | #include <asm/mach-au1x00/au1000.h> |
| @@ -120,8 +122,8 @@ struct au1000_state { | |||
| 120 | int no_vra; // do not use VRA | 122 | int no_vra; // do not use VRA |
| 121 | 123 | ||
| 122 | spinlock_t lock; | 124 | spinlock_t lock; |
| 123 | struct semaphore open_sem; | 125 | struct mutex open_mutex; |
| 124 | struct semaphore sem; | 126 | struct mutex sem; |
| 125 | mode_t open_mode; | 127 | mode_t open_mode; |
| 126 | wait_queue_head_t open_wait; | 128 | wait_queue_head_t open_wait; |
| 127 | 129 | ||
| @@ -1106,7 +1108,7 @@ static ssize_t au1000_read(struct file *file, char *buffer, | |||
| 1106 | 1108 | ||
| 1107 | count *= db->cnt_factor; | 1109 | count *= db->cnt_factor; |
| 1108 | 1110 | ||
| 1109 | down(&s->sem); | 1111 | mutex_lock(&s->sem); |
| 1110 | add_wait_queue(&db->wait, &wait); | 1112 | add_wait_queue(&db->wait, &wait); |
| 1111 | 1113 | ||
| 1112 | while (count > 0) { | 1114 | while (count > 0) { |
| @@ -1125,14 +1127,14 @@ static ssize_t au1000_read(struct file *file, char *buffer, | |||
| 1125 | ret = -EAGAIN; | 1127 | ret = -EAGAIN; |
| 1126 | goto out; | 1128 | goto out; |
| 1127 | } | 1129 | } |
| 1128 | up(&s->sem); | 1130 | mutex_unlock(&s->sem); |
| 1129 | schedule(); | 1131 | schedule(); |
| 1130 | if (signal_pending(current)) { | 1132 | if (signal_pending(current)) { |
| 1131 | if (!ret) | 1133 | if (!ret) |
| 1132 | ret = -ERESTARTSYS; | 1134 | ret = -ERESTARTSYS; |
| 1133 | goto out2; | 1135 | goto out2; |
| 1134 | } | 1136 | } |
| 1135 | down(&s->sem); | 1137 | mutex_lock(&s->sem); |
| 1136 | } | 1138 | } |
| 1137 | } while (avail <= 0); | 1139 | } while (avail <= 0); |
| 1138 | 1140 | ||
| @@ -1159,7 +1161,7 @@ static ssize_t au1000_read(struct file *file, char *buffer, | |||
| 1159 | } // while (count > 0) | 1161 | } // while (count > 0) |
| 1160 | 1162 | ||
| 1161 | out: | 1163 | out: |
| 1162 | up(&s->sem); | 1164 | mutex_unlock(&s->sem); |
| 1163 | out2: | 1165 | out2: |
| 1164 | remove_wait_queue(&db->wait, &wait); | 1166 | remove_wait_queue(&db->wait, &wait); |
| 1165 | set_current_state(TASK_RUNNING); | 1167 | set_current_state(TASK_RUNNING); |
| @@ -1187,7 +1189,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer, | |||
| 1187 | 1189 | ||
| 1188 | count *= db->cnt_factor; | 1190 | count *= db->cnt_factor; |
| 1189 | 1191 | ||
| 1190 | down(&s->sem); | 1192 | mutex_lock(&s->sem); |
| 1191 | add_wait_queue(&db->wait, &wait); | 1193 | add_wait_queue(&db->wait, &wait); |
| 1192 | 1194 | ||
| 1193 | while (count > 0) { | 1195 | while (count > 0) { |
| @@ -1204,14 +1206,14 @@ static ssize_t au1000_write(struct file *file, const char *buffer, | |||
| 1204 | ret = -EAGAIN; | 1206 | ret = -EAGAIN; |
| 1205 | goto out; | 1207 | goto out; |
| 1206 | } | 1208 | } |
| 1207 | up(&s->sem); | 1209 | mutex_unlock(&s->sem); |
| 1208 | schedule(); | 1210 | schedule(); |
| 1209 | if (signal_pending(current)) { | 1211 | if (signal_pending(current)) { |
| 1210 | if (!ret) | 1212 | if (!ret) |
| 1211 | ret = -ERESTARTSYS; | 1213 | ret = -ERESTARTSYS; |
| 1212 | goto out2; | 1214 | goto out2; |
| 1213 | } | 1215 | } |
| 1214 | down(&s->sem); | 1216 | mutex_lock(&s->sem); |
| 1215 | } | 1217 | } |
| 1216 | } while (avail <= 0); | 1218 | } while (avail <= 0); |
| 1217 | 1219 | ||
| @@ -1240,7 +1242,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer, | |||
| 1240 | } // while (count > 0) | 1242 | } // while (count > 0) |
| 1241 | 1243 | ||
| 1242 | out: | 1244 | out: |
| 1243 | up(&s->sem); | 1245 | mutex_unlock(&s->sem); |
| 1244 | out2: | 1246 | out2: |
| 1245 | remove_wait_queue(&db->wait, &wait); | 1247 | remove_wait_queue(&db->wait, &wait); |
| 1246 | set_current_state(TASK_RUNNING); | 1248 | set_current_state(TASK_RUNNING); |
| @@ -1298,7 +1300,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 1298 | dbg("%s", __FUNCTION__); | 1300 | dbg("%s", __FUNCTION__); |
| 1299 | 1301 | ||
| 1300 | lock_kernel(); | 1302 | lock_kernel(); |
| 1301 | down(&s->sem); | 1303 | mutex_lock(&s->sem); |
| 1302 | if (vma->vm_flags & VM_WRITE) | 1304 | if (vma->vm_flags & VM_WRITE) |
| 1303 | db = &s->dma_dac; | 1305 | db = &s->dma_dac; |
| 1304 | else if (vma->vm_flags & VM_READ) | 1306 | else if (vma->vm_flags & VM_READ) |
| @@ -1324,7 +1326,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 1324 | vma->vm_flags &= ~VM_IO; | 1326 | vma->vm_flags &= ~VM_IO; |
| 1325 | db->mapped = 1; | 1327 | db->mapped = 1; |
| 1326 | out: | 1328 | out: |
| 1327 | up(&s->sem); | 1329 | mutex_unlock(&s->sem); |
| 1328 | unlock_kernel(); | 1330 | unlock_kernel(); |
| 1329 | return ret; | 1331 | return ret; |
| 1330 | } | 1332 | } |
| @@ -1829,21 +1831,21 @@ static int au1000_open(struct inode *inode, struct file *file) | |||
| 1829 | 1831 | ||
| 1830 | file->private_data = s; | 1832 | file->private_data = s; |
| 1831 | /* wait for device to become free */ | 1833 | /* wait for device to become free */ |
| 1832 | down(&s->open_sem); | 1834 | mutex_lock(&s->open_mutex); |
| 1833 | while (s->open_mode & file->f_mode) { | 1835 | while (s->open_mode & file->f_mode) { |
| 1834 | if (file->f_flags & O_NONBLOCK) { | 1836 | if (file->f_flags & O_NONBLOCK) { |
| 1835 | up(&s->open_sem); | 1837 | mutex_unlock(&s->open_mutex); |
| 1836 | return -EBUSY; | 1838 | return -EBUSY; |
| 1837 | } | 1839 | } |
| 1838 | add_wait_queue(&s->open_wait, &wait); | 1840 | add_wait_queue(&s->open_wait, &wait); |
| 1839 | __set_current_state(TASK_INTERRUPTIBLE); | 1841 | __set_current_state(TASK_INTERRUPTIBLE); |
| 1840 | up(&s->open_sem); | 1842 | mutex_unlock(&s->open_mutex); |
| 1841 | schedule(); | 1843 | schedule(); |
| 1842 | remove_wait_queue(&s->open_wait, &wait); | 1844 | remove_wait_queue(&s->open_wait, &wait); |
| 1843 | set_current_state(TASK_RUNNING); | 1845 | set_current_state(TASK_RUNNING); |
| 1844 | if (signal_pending(current)) | 1846 | if (signal_pending(current)) |
| 1845 | return -ERESTARTSYS; | 1847 | return -ERESTARTSYS; |
| 1846 | down(&s->open_sem); | 1848 | mutex_lock(&s->open_mutex); |
| 1847 | } | 1849 | } |
| 1848 | 1850 | ||
| 1849 | stop_dac(s); | 1851 | stop_dac(s); |
| @@ -1879,8 +1881,8 @@ static int au1000_open(struct inode *inode, struct file *file) | |||
| 1879 | } | 1881 | } |
| 1880 | 1882 | ||
| 1881 | s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); | 1883 | s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); |
| 1882 | up(&s->open_sem); | 1884 | mutex_unlock(&s->open_mutex); |
| 1883 | init_MUTEX(&s->sem); | 1885 | mutex_init(&s->sem); |
| 1884 | return nonseekable_open(inode, file); | 1886 | return nonseekable_open(inode, file); |
| 1885 | } | 1887 | } |
| 1886 | 1888 | ||
| @@ -1896,7 +1898,7 @@ static int au1000_release(struct inode *inode, struct file *file) | |||
| 1896 | lock_kernel(); | 1898 | lock_kernel(); |
| 1897 | } | 1899 | } |
| 1898 | 1900 | ||
| 1899 | down(&s->open_sem); | 1901 | mutex_lock(&s->open_mutex); |
| 1900 | if (file->f_mode & FMODE_WRITE) { | 1902 | if (file->f_mode & FMODE_WRITE) { |
| 1901 | stop_dac(s); | 1903 | stop_dac(s); |
| 1902 | dealloc_dmabuf(s, &s->dma_dac); | 1904 | dealloc_dmabuf(s, &s->dma_dac); |
| @@ -1906,7 +1908,7 @@ static int au1000_release(struct inode *inode, struct file *file) | |||
| 1906 | dealloc_dmabuf(s, &s->dma_adc); | 1908 | dealloc_dmabuf(s, &s->dma_adc); |
| 1907 | } | 1909 | } |
| 1908 | s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); | 1910 | s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); |
| 1909 | up(&s->open_sem); | 1911 | mutex_unlock(&s->open_mutex); |
| 1910 | wake_up(&s->open_wait); | 1912 | wake_up(&s->open_wait); |
| 1911 | unlock_kernel(); | 1913 | unlock_kernel(); |
| 1912 | return 0; | 1914 | return 0; |
| @@ -1996,7 +1998,7 @@ static int __devinit au1000_probe(void) | |||
| 1996 | init_waitqueue_head(&s->dma_adc.wait); | 1998 | init_waitqueue_head(&s->dma_adc.wait); |
| 1997 | init_waitqueue_head(&s->dma_dac.wait); | 1999 | init_waitqueue_head(&s->dma_dac.wait); |
| 1998 | init_waitqueue_head(&s->open_wait); | 2000 | init_waitqueue_head(&s->open_wait); |
| 1999 | init_MUTEX(&s->open_sem); | 2001 | mutex_init(&s->open_mutex); |
| 2000 | spin_lock_init(&s->lock); | 2002 | spin_lock_init(&s->lock); |
| 2001 | s->codec.private_data = s; | 2003 | s->codec.private_data = s; |
| 2002 | s->codec.id = 0; | 2004 | s->codec.id = 0; |
