aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-03-23 06:00:39 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:13 -0500
commit910f5d202ce39cc78de1bbb679285a3167de9fb2 (patch)
tree2c5b55c2b141aaf016c459beb397fc702c41b967 /sound
parent82d4dc5adb0055393248ad4ab8de392fac708a12 (diff)
[PATCH] sem2mutex: sound/oss/
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/oss/aci.c11
-rw-r--r--sound/oss/ad1889.c7
-rw-r--r--sound/oss/ad1889.h2
-rw-r--r--sound/oss/ali5455.c8
-rw-r--r--sound/oss/au1000.c44
-rw-r--r--sound/oss/au1550_ac97.c44
-rw-r--r--sound/oss/btaudio.c36
-rw-r--r--sound/oss/cmpci.c20
-rw-r--r--sound/oss/cs46xx.c75
-rw-r--r--sound/oss/es1370.c71
-rw-r--r--sound/oss/es1371.c71
-rw-r--r--sound/oss/esssolo1.c50
-rw-r--r--sound/oss/forte.c11
-rw-r--r--sound/oss/hal2.c22
-rw-r--r--sound/oss/i810_audio.c8
-rw-r--r--sound/oss/ite8172.c20
-rw-r--r--sound/oss/maestro.c26
-rw-r--r--sound/oss/maestro3.c20
-rw-r--r--sound/oss/nec_vrc5477.c20
-rw-r--r--sound/oss/rme96xx.c17
-rw-r--r--sound/oss/sonicvibes.c48
-rw-r--r--sound/oss/swarm_cs4297a.c39
-rw-r--r--sound/oss/trident.c62
-rw-r--r--sound/oss/via82cxxx_audio.c49
-rw-r--r--sound/oss/vwsnd.c61
-rw-r--r--sound/oss/ymfpci.c14
-rw-r--r--sound/oss/ymfpci.h3
27 files changed, 449 insertions, 410 deletions
diff --git a/sound/oss/aci.c b/sound/oss/aci.c
index 3928c2802cc4..3bfac375dbdb 100644
--- a/sound/oss/aci.c
+++ b/sound/oss/aci.c
@@ -56,7 +56,8 @@
56#include <linux/module.h> 56#include <linux/module.h>
57#include <linux/proc_fs.h> 57#include <linux/proc_fs.h>
58#include <linux/slab.h> 58#include <linux/slab.h>
59#include <asm/semaphore.h> 59#include <linux/mutex.h>
60
60#include <asm/io.h> 61#include <asm/io.h>
61#include <asm/uaccess.h> 62#include <asm/uaccess.h>
62#include "sound_config.h" 63#include "sound_config.h"
@@ -79,7 +80,7 @@ static int aci_micpreamp=3; /* microphone preamp-level that can't be *
79 * checked with ACI versions prior to 0xb0 */ 80 * checked with ACI versions prior to 0xb0 */
80 81
81static int mixer_device; 82static int mixer_device;
82static struct semaphore aci_sem; 83static struct mutex aci_mutex;
83 84
84#ifdef MODULE 85#ifdef MODULE
85static int reset; 86static int reset;
@@ -212,7 +213,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
212 int write[] = {write1, write2, write3}; 213 int write[] = {write1, write2, write3};
213 int read = -EINTR, i; 214 int read = -EINTR, i;
214 215
215 if (down_interruptible(&aci_sem)) 216 if (mutex_lock_interruptible(&aci_mutex))
216 goto out; 217 goto out;
217 218
218 for (i=0; i<3; i++) { 219 for (i=0; i<3; i++) {
@@ -227,7 +228,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
227 } 228 }
228 229
229 read = aci_rawread(); 230 read = aci_rawread();
230out_up: up(&aci_sem); 231out_up: mutex_unlock(&aci_mutex);
231out: return read; 232out: return read;
232} 233}
233 234
@@ -603,7 +604,7 @@ static int __init attach_aci(void)
603 char *boardname; 604 char *boardname;
604 int i, rc = -EBUSY; 605 int i, rc = -EBUSY;
605 606
606 init_MUTEX(&aci_sem); 607 mutex_init(&aci_mutex);
607 608
608 outb(0xE3, 0xf8f); /* Write MAD16 password */ 609 outb(0xE3, 0xf8f); /* Write MAD16 password */
609 aci_port = (inb(0xf90) & 0x10) ? 610 aci_port = (inb(0xf90) & 0x10) ?
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c
index a0d73f343100..54dabf862802 100644
--- a/sound/oss/ad1889.c
+++ b/sound/oss/ad1889.c
@@ -38,6 +38,7 @@
38#include <linux/ac97_codec.h> 38#include <linux/ac97_codec.h>
39#include <linux/sound.h> 39#include <linux/sound.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/mutex.h>
41 42
42#include <asm/delay.h> 43#include <asm/delay.h>
43#include <asm/io.h> 44#include <asm/io.h>
@@ -238,7 +239,7 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
238 239
239 for (i = 0; i < AD_MAX_STATES; i++) { 240 for (i = 0; i < AD_MAX_STATES; i++) {
240 dev->state[i].card = dev; 241 dev->state[i].card = dev;
241 init_MUTEX(&dev->state[i].sem); 242 mutex_init(&dev->state[i].mutex);
242 init_waitqueue_head(&dev->state[i].dmabuf.wait); 243 init_waitqueue_head(&dev->state[i].dmabuf.wait);
243 } 244 }
244 245
@@ -461,7 +462,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
461 ssize_t ret = 0; 462 ssize_t ret = 0;
462 DECLARE_WAITQUEUE(wait, current); 463 DECLARE_WAITQUEUE(wait, current);
463 464
464 down(&state->sem); 465 mutex_lock(&state->mutex);
465#if 0 466#if 0
466 if (dmabuf->mapped) { 467 if (dmabuf->mapped) {
467 ret = -ENXIO; 468 ret = -ENXIO;
@@ -546,7 +547,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
546err2: 547err2:
547 remove_wait_queue(&state->dmabuf.wait, &wait); 548 remove_wait_queue(&state->dmabuf.wait, &wait);
548err1: 549err1:
549 up(&state->sem); 550 mutex_unlock(&state->mutex);
550 return ret; 551 return ret;
551} 552}
552 553
diff --git a/sound/oss/ad1889.h b/sound/oss/ad1889.h
index e04affce1dd1..861b3213f30b 100644
--- a/sound/oss/ad1889.h
+++ b/sound/oss/ad1889.h
@@ -100,7 +100,7 @@ typedef struct ad1889_state {
100 unsigned int subdivision; 100 unsigned int subdivision;
101 } dmabuf; 101 } dmabuf;
102 102
103 struct semaphore sem; 103 struct mutex mutex;
104} ad1889_state_t; 104} ad1889_state_t;
105 105
106typedef struct ad1889_dev { 106typedef struct ad1889_dev {
diff --git a/sound/oss/ali5455.c b/sound/oss/ali5455.c
index 9c9e6c0410f2..62bb936b1f3d 100644
--- a/sound/oss/ali5455.c
+++ b/sound/oss/ali5455.c
@@ -64,6 +64,8 @@
64#include <linux/smp_lock.h> 64#include <linux/smp_lock.h>
65#include <linux/ac97_codec.h> 65#include <linux/ac97_codec.h>
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <linux/mutex.h>
68
67#include <asm/uaccess.h> 69#include <asm/uaccess.h>
68 70
69#ifndef PCI_DEVICE_ID_ALI_5455 71#ifndef PCI_DEVICE_ID_ALI_5455
@@ -234,7 +236,7 @@ struct ali_state {
234 struct ali_card *card; /* Card info */ 236 struct ali_card *card; /* Card info */
235 237
236 /* single open lock mechanism, only used for recording */ 238 /* single open lock mechanism, only used for recording */
237 struct semaphore open_sem; 239 struct mutex open_mutex;
238 wait_queue_head_t open_wait; 240 wait_queue_head_t open_wait;
239 241
240 /* file mode */ 242 /* file mode */
@@ -2807,7 +2809,7 @@ found_virt:
2807 state->card = card; 2809 state->card = card;
2808 state->magic = ALI5455_STATE_MAGIC; 2810 state->magic = ALI5455_STATE_MAGIC;
2809 init_waitqueue_head(&dmabuf->wait); 2811 init_waitqueue_head(&dmabuf->wait);
2810 init_MUTEX(&state->open_sem); 2812 mutex_init(&state->open_mutex);
2811 file->private_data = state; 2813 file->private_data = state;
2812 dmabuf->trigger = 0; 2814 dmabuf->trigger = 0;
2813 /* allocate hardware channels */ 2815 /* allocate hardware channels */
@@ -3359,7 +3361,7 @@ static void __devinit ali_configure_clocking(void)
3359 state->card = card; 3361 state->card = card;
3360 state->magic = ALI5455_STATE_MAGIC; 3362 state->magic = ALI5455_STATE_MAGIC;
3361 init_waitqueue_head(&dmabuf->wait); 3363 init_waitqueue_head(&dmabuf->wait);
3362 init_MUTEX(&state->open_sem); 3364 mutex_init(&state->open_mutex);
3363 dmabuf->fmt = ALI5455_FMT_STEREO | ALI5455_FMT_16BIT; 3365 dmabuf->fmt = ALI5455_FMT_STEREO | ALI5455_FMT_16BIT;
3364 dmabuf->trigger = PCM_ENABLE_OUTPUT; 3366 dmabuf->trigger = PCM_ENABLE_OUTPUT;
3365 ali_set_dac_rate(state, 48000); 3367 ali_set_dac_rate(state, 48000);
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
1161out: 1163out:
1162 up(&s->sem); 1164 mutex_unlock(&s->sem);
1163out2: 1165out2:
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
1242out: 1244out:
1243 up(&s->sem); 1245 mutex_unlock(&s->sem);
1244out2: 1246out2:
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;
1326out: 1328out:
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;
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();
diff --git a/sound/oss/btaudio.c b/sound/oss/btaudio.c
index 4007a5680acb..bfe3b534ef30 100644
--- a/sound/oss/btaudio.c
+++ b/sound/oss/btaudio.c
@@ -32,6 +32,8 @@
32#include <linux/soundcard.h> 32#include <linux/soundcard.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/kdev_t.h> 34#include <linux/kdev_t.h>
35#include <linux/mutex.h>
36
35#include <asm/uaccess.h> 37#include <asm/uaccess.h>
36#include <asm/io.h> 38#include <asm/io.h>
37 39
@@ -108,7 +110,7 @@ struct btaudio {
108 110
109 /* locking */ 111 /* locking */
110 int users; 112 int users;
111 struct semaphore lock; 113 struct mutex lock;
112 114
113 /* risc instructions */ 115 /* risc instructions */
114 unsigned int risc_size; 116 unsigned int risc_size;
@@ -440,7 +442,7 @@ static struct file_operations btaudio_mixer_fops = {
440static int btaudio_dsp_open(struct inode *inode, struct file *file, 442static int btaudio_dsp_open(struct inode *inode, struct file *file,
441 struct btaudio *bta, int analog) 443 struct btaudio *bta, int analog)
442{ 444{
443 down(&bta->lock); 445 mutex_lock(&bta->lock);
444 if (bta->users) 446 if (bta->users)
445 goto busy; 447 goto busy;
446 bta->users++; 448 bta->users++;
@@ -452,11 +454,11 @@ static int btaudio_dsp_open(struct inode *inode, struct file *file,
452 bta->read_count = 0; 454 bta->read_count = 0;
453 bta->sampleshift = 0; 455 bta->sampleshift = 0;
454 456
455 up(&bta->lock); 457 mutex_unlock(&bta->lock);
456 return 0; 458 return 0;
457 459
458 busy: 460 busy:
459 up(&bta->lock); 461 mutex_unlock(&bta->lock);
460 return -EBUSY; 462 return -EBUSY;
461} 463}
462 464
@@ -496,11 +498,11 @@ static int btaudio_dsp_release(struct inode *inode, struct file *file)
496{ 498{
497 struct btaudio *bta = file->private_data; 499 struct btaudio *bta = file->private_data;
498 500
499 down(&bta->lock); 501 mutex_lock(&bta->lock);
500 if (bta->recording) 502 if (bta->recording)
501 stop_recording(bta); 503 stop_recording(bta);
502 bta->users--; 504 bta->users--;
503 up(&bta->lock); 505 mutex_unlock(&bta->lock);
504 return 0; 506 return 0;
505} 507}
506 508
@@ -513,7 +515,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
513 DECLARE_WAITQUEUE(wait, current); 515 DECLARE_WAITQUEUE(wait, current);
514 516
515 add_wait_queue(&bta->readq, &wait); 517 add_wait_queue(&bta->readq, &wait);
516 down(&bta->lock); 518 mutex_lock(&bta->lock);
517 while (swcount > 0) { 519 while (swcount > 0) {
518 if (0 == bta->read_count) { 520 if (0 == bta->read_count) {
519 if (!bta->recording) { 521 if (!bta->recording) {
@@ -528,10 +530,10 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
528 ret = -EAGAIN; 530 ret = -EAGAIN;
529 break; 531 break;
530 } 532 }
531 up(&bta->lock); 533 mutex_unlock(&bta->lock);
532 current->state = TASK_INTERRUPTIBLE; 534 current->state = TASK_INTERRUPTIBLE;
533 schedule(); 535 schedule();
534 down(&bta->lock); 536 mutex_lock(&bta->lock);
535 if(signal_pending(current)) { 537 if(signal_pending(current)) {
536 if (0 == ret) 538 if (0 == ret)
537 ret = -EINTR; 539 ret = -EINTR;
@@ -604,7 +606,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
604 if (bta->read_offset == bta->buf_size) 606 if (bta->read_offset == bta->buf_size)
605 bta->read_offset = 0; 607 bta->read_offset = 0;
606 } 608 }
607 up(&bta->lock); 609 mutex_unlock(&bta->lock);
608 remove_wait_queue(&bta->readq, &wait); 610 remove_wait_queue(&bta->readq, &wait);
609 current->state = TASK_RUNNING; 611 current->state = TASK_RUNNING;
610 return ret; 612 return ret;
@@ -651,10 +653,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
651 bta->decimation = 0; 653 bta->decimation = 0;
652 } 654 }
653 if (bta->recording) { 655 if (bta->recording) {
654 down(&bta->lock); 656 mutex_lock(&bta->lock);
655 stop_recording(bta); 657 stop_recording(bta);
656 start_recording(bta); 658 start_recording(bta);
657 up(&bta->lock); 659 mutex_unlock(&bta->lock);
658 } 660 }
659 /* fall through */ 661 /* fall through */
660 case SOUND_PCM_READ_RATE: 662 case SOUND_PCM_READ_RATE:
@@ -716,10 +718,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
716 else 718 else
717 bta->bits = 16; 719 bta->bits = 16;
718 if (bta->recording) { 720 if (bta->recording) {
719 down(&bta->lock); 721 mutex_lock(&bta->lock);
720 stop_recording(bta); 722 stop_recording(bta);
721 start_recording(bta); 723 start_recording(bta);
722 up(&bta->lock); 724 mutex_unlock(&bta->lock);
723 } 725 }
724 } 726 }
725 if (debug) 727 if (debug)
@@ -736,9 +738,9 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
736 738
737 case SNDCTL_DSP_RESET: 739 case SNDCTL_DSP_RESET:
738 if (bta->recording) { 740 if (bta->recording) {
739 down(&bta->lock); 741 mutex_lock(&bta->lock);
740 stop_recording(bta); 742 stop_recording(bta);
741 up(&bta->lock); 743 mutex_unlock(&bta->lock);
742 } 744 }
743 return 0; 745 return 0;
744 case SNDCTL_DSP_GETBLKSIZE: 746 case SNDCTL_DSP_GETBLKSIZE:
@@ -941,7 +943,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
941 if (rate) 943 if (rate)
942 bta->rate = rate; 944 bta->rate = rate;
943 945
944 init_MUTEX(&bta->lock); 946 mutex_init(&bta->lock);
945 init_waitqueue_head(&bta->readq); 947 init_waitqueue_head(&bta->readq);
946 948
947 if (-1 != latency) { 949 if (-1 != latency) {
diff --git a/sound/oss/cmpci.c b/sound/oss/cmpci.c
index 7cfbb08db537..1fbd5137f6d7 100644
--- a/sound/oss/cmpci.c
+++ b/sound/oss/cmpci.c
@@ -138,6 +138,8 @@
138#endif 138#endif
139#ifdef CONFIG_SOUND_CMPCI_JOYSTICK 139#ifdef CONFIG_SOUND_CMPCI_JOYSTICK
140#include <linux/gameport.h> 140#include <linux/gameport.h>
141#include <linux/mutex.h>
142
141#endif 143#endif
142 144
143/* --------------------------------------------------------------------- */ 145/* --------------------------------------------------------------------- */
@@ -392,7 +394,7 @@ struct cm_state {
392 unsigned char fmt, enable; 394 unsigned char fmt, enable;
393 395
394 spinlock_t lock; 396 spinlock_t lock;
395 struct semaphore open_sem; 397 struct mutex open_mutex;
396 mode_t open_mode; 398 mode_t open_mode;
397 wait_queue_head_t open_wait; 399 wait_queue_head_t open_wait;
398 400
@@ -2825,21 +2827,21 @@ static int cm_open(struct inode *inode, struct file *file)
2825 VALIDATE_STATE(s); 2827 VALIDATE_STATE(s);
2826 file->private_data = s; 2828 file->private_data = s;
2827 /* wait for device to become free */ 2829 /* wait for device to become free */
2828 down(&s->open_sem); 2830 mutex_lock(&s->open_mutex);
2829 while (s->open_mode & file->f_mode) { 2831 while (s->open_mode & file->f_mode) {
2830 if (file->f_flags & O_NONBLOCK) { 2832 if (file->f_flags & O_NONBLOCK) {
2831 up(&s->open_sem); 2833 mutex_unlock(&s->open_mutex);
2832 return -EBUSY; 2834 return -EBUSY;
2833 } 2835 }
2834 add_wait_queue(&s->open_wait, &wait); 2836 add_wait_queue(&s->open_wait, &wait);
2835 __set_current_state(TASK_INTERRUPTIBLE); 2837 __set_current_state(TASK_INTERRUPTIBLE);
2836 up(&s->open_sem); 2838 mutex_unlock(&s->open_mutex);
2837 schedule(); 2839 schedule();
2838 remove_wait_queue(&s->open_wait, &wait); 2840 remove_wait_queue(&s->open_wait, &wait);
2839 set_current_state(TASK_RUNNING); 2841 set_current_state(TASK_RUNNING);
2840 if (signal_pending(current)) 2842 if (signal_pending(current))
2841 return -ERESTARTSYS; 2843 return -ERESTARTSYS;
2842 down(&s->open_sem); 2844 mutex_lock(&s->open_mutex);
2843 } 2845 }
2844 if (file->f_mode & FMODE_READ) { 2846 if (file->f_mode & FMODE_READ) {
2845 s->status &= ~DO_BIGENDIAN_R; 2847 s->status &= ~DO_BIGENDIAN_R;
@@ -2867,7 +2869,7 @@ static int cm_open(struct inode *inode, struct file *file)
2867 } 2869 }
2868 set_fmt(s, fmtm, fmts); 2870 set_fmt(s, fmtm, fmts);
2869 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2871 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2870 up(&s->open_sem); 2872 mutex_unlock(&s->open_mutex);
2871 return nonseekable_open(inode, file); 2873 return nonseekable_open(inode, file);
2872} 2874}
2873 2875
@@ -2879,7 +2881,7 @@ static int cm_release(struct inode *inode, struct file *file)
2879 lock_kernel(); 2881 lock_kernel();
2880 if (file->f_mode & FMODE_WRITE) 2882 if (file->f_mode & FMODE_WRITE)
2881 drain_dac(s, file->f_flags & O_NONBLOCK); 2883 drain_dac(s, file->f_flags & O_NONBLOCK);
2882 down(&s->open_sem); 2884 mutex_lock(&s->open_mutex);
2883 if (file->f_mode & FMODE_WRITE) { 2885 if (file->f_mode & FMODE_WRITE) {
2884 stop_dac(s); 2886 stop_dac(s);
2885 2887
@@ -2903,7 +2905,7 @@ static int cm_release(struct inode *inode, struct file *file)
2903 s->status &= ~DO_BIGENDIAN_R; 2905 s->status &= ~DO_BIGENDIAN_R;
2904 } 2906 }
2905 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 2907 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
2906 up(&s->open_sem); 2908 mutex_unlock(&s->open_mutex);
2907 wake_up(&s->open_wait); 2909 wake_up(&s->open_wait);
2908 unlock_kernel(); 2910 unlock_kernel();
2909 return 0; 2911 return 0;
@@ -3080,7 +3082,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id
3080 init_waitqueue_head(&s->dma_adc.wait); 3082 init_waitqueue_head(&s->dma_adc.wait);
3081 init_waitqueue_head(&s->dma_dac.wait); 3083 init_waitqueue_head(&s->dma_dac.wait);
3082 init_waitqueue_head(&s->open_wait); 3084 init_waitqueue_head(&s->open_wait);
3083 init_MUTEX(&s->open_sem); 3085 mutex_init(&s->open_mutex);
3084 spin_lock_init(&s->lock); 3086 spin_lock_init(&s->lock);
3085 s->magic = CM_MAGIC; 3087 s->magic = CM_MAGIC;
3086 s->dev = pcidev; 3088 s->dev = pcidev;
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
index 58e25c82eaf2..53881bc91bba 100644
--- a/sound/oss/cs46xx.c
+++ b/sound/oss/cs46xx.c
@@ -90,6 +90,7 @@
90#include <linux/init.h> 90#include <linux/init.h>
91#include <linux/poll.h> 91#include <linux/poll.h>
92#include <linux/ac97_codec.h> 92#include <linux/ac97_codec.h>
93#include <linux/mutex.h>
93 94
94#include <asm/io.h> 95#include <asm/io.h>
95#include <asm/dma.h> 96#include <asm/dma.h>
@@ -238,7 +239,7 @@ struct cs_state {
238 struct cs_card *card; /* Card info */ 239 struct cs_card *card; /* Card info */
239 240
240 /* single open lock mechanism, only used for recording */ 241 /* single open lock mechanism, only used for recording */
241 struct semaphore open_sem; 242 struct mutex open_mutex;
242 wait_queue_head_t open_wait; 243 wait_queue_head_t open_wait;
243 244
244 /* file mode */ 245 /* file mode */
@@ -297,7 +298,7 @@ struct cs_state {
297 unsigned subdivision; 298 unsigned subdivision;
298 } dmabuf; 299 } dmabuf;
299 /* Guard against mmap/write/read races */ 300 /* Guard against mmap/write/read races */
300 struct semaphore sem; 301 struct mutex sem;
301}; 302};
302 303
303struct cs_card { 304struct cs_card {
@@ -375,7 +376,7 @@ struct cs_card {
375 unsigned char ibuf[CS_MIDIINBUF]; 376 unsigned char ibuf[CS_MIDIINBUF];
376 unsigned char obuf[CS_MIDIOUTBUF]; 377 unsigned char obuf[CS_MIDIOUTBUF];
377 mode_t open_mode; 378 mode_t open_mode;
378 struct semaphore open_sem; 379 struct mutex open_mutex;
379 } midi; 380 } midi;
380 struct cs46xx_pm pm; 381 struct cs46xx_pm pm;
381}; 382};
@@ -1428,9 +1429,9 @@ static int prog_dmabuf(struct cs_state *state)
1428{ 1429{
1429 int ret; 1430 int ret;
1430 1431
1431 down(&state->sem); 1432 mutex_lock(&state->sem);
1432 ret = __prog_dmabuf(state); 1433 ret = __prog_dmabuf(state);
1433 up(&state->sem); 1434 mutex_unlock(&state->sem);
1434 1435
1435 return ret; 1436 return ret;
1436} 1437}
@@ -1831,17 +1832,17 @@ static int cs_midi_open(struct inode *inode, struct file *file)
1831 1832
1832 file->private_data = card; 1833 file->private_data = card;
1833 /* wait for device to become free */ 1834 /* wait for device to become free */
1834 down(&card->midi.open_sem); 1835 mutex_lock(&card->midi.open_mutex);
1835 while (card->midi.open_mode & file->f_mode) { 1836 while (card->midi.open_mode & file->f_mode) {
1836 if (file->f_flags & O_NONBLOCK) { 1837 if (file->f_flags & O_NONBLOCK) {
1837 up(&card->midi.open_sem); 1838 mutex_unlock(&card->midi.open_mutex);
1838 return -EBUSY; 1839 return -EBUSY;
1839 } 1840 }
1840 up(&card->midi.open_sem); 1841 mutex_unlock(&card->midi.open_mutex);
1841 interruptible_sleep_on(&card->midi.open_wait); 1842 interruptible_sleep_on(&card->midi.open_wait);
1842 if (signal_pending(current)) 1843 if (signal_pending(current))
1843 return -ERESTARTSYS; 1844 return -ERESTARTSYS;
1844 down(&card->midi.open_sem); 1845 mutex_lock(&card->midi.open_mutex);
1845 } 1846 }
1846 spin_lock_irqsave(&card->midi.lock, flags); 1847 spin_lock_irqsave(&card->midi.lock, flags);
1847 if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) { 1848 if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) {
@@ -1859,7 +1860,7 @@ static int cs_midi_open(struct inode *inode, struct file *file)
1859 } 1860 }
1860 spin_unlock_irqrestore(&card->midi.lock, flags); 1861 spin_unlock_irqrestore(&card->midi.lock, flags);
1861 card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); 1862 card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
1862 up(&card->midi.open_sem); 1863 mutex_unlock(&card->midi.open_mutex);
1863 return 0; 1864 return 0;
1864} 1865}
1865 1866
@@ -1891,9 +1892,9 @@ static int cs_midi_release(struct inode *inode, struct file *file)
1891 remove_wait_queue(&card->midi.owait, &wait); 1892 remove_wait_queue(&card->midi.owait, &wait);
1892 current->state = TASK_RUNNING; 1893 current->state = TASK_RUNNING;
1893 } 1894 }
1894 down(&card->midi.open_sem); 1895 mutex_lock(&card->midi.open_mutex);
1895 card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE))); 1896 card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE)));
1896 up(&card->midi.open_sem); 1897 mutex_unlock(&card->midi.open_mutex);
1897 wake_up(&card->midi.open_wait); 1898 wake_up(&card->midi.open_wait);
1898 return 0; 1899 return 0;
1899} 1900}
@@ -2081,7 +2082,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
2081 if (!access_ok(VERIFY_WRITE, buffer, count)) 2082 if (!access_ok(VERIFY_WRITE, buffer, count))
2082 return -EFAULT; 2083 return -EFAULT;
2083 2084
2084 down(&state->sem); 2085 mutex_lock(&state->sem);
2085 if (!dmabuf->ready && (ret = __prog_dmabuf(state))) 2086 if (!dmabuf->ready && (ret = __prog_dmabuf(state)))
2086 goto out2; 2087 goto out2;
2087 2088
@@ -2114,13 +2115,13 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
2114 if (!ret) ret = -EAGAIN; 2115 if (!ret) ret = -EAGAIN;
2115 goto out; 2116 goto out;
2116 } 2117 }
2117 up(&state->sem); 2118 mutex_unlock(&state->sem);
2118 schedule(); 2119 schedule();
2119 if (signal_pending(current)) { 2120 if (signal_pending(current)) {
2120 if(!ret) ret = -ERESTARTSYS; 2121 if(!ret) ret = -ERESTARTSYS;
2121 goto out; 2122 goto out;
2122 } 2123 }
2123 down(&state->sem); 2124 mutex_lock(&state->sem);
2124 if (dmabuf->mapped) 2125 if (dmabuf->mapped)
2125 { 2126 {
2126 if(!ret) 2127 if(!ret)
@@ -2155,7 +2156,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
2155out: 2156out:
2156 remove_wait_queue(&state->dmabuf.wait, &wait); 2157 remove_wait_queue(&state->dmabuf.wait, &wait);
2157out2: 2158out2:
2158 up(&state->sem); 2159 mutex_unlock(&state->sem);
2159 set_current_state(TASK_RUNNING); 2160 set_current_state(TASK_RUNNING);
2160 CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4, 2161 CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4,
2161 printk("cs46xx: cs_read()- %zd\n",ret) ); 2162 printk("cs46xx: cs_read()- %zd\n",ret) );
@@ -2184,7 +2185,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
2184 return -EFAULT; 2185 return -EFAULT;
2185 dmabuf = &state->dmabuf; 2186 dmabuf = &state->dmabuf;
2186 2187
2187 down(&state->sem); 2188 mutex_lock(&state->sem);
2188 if (dmabuf->mapped) 2189 if (dmabuf->mapped)
2189 { 2190 {
2190 ret = -ENXIO; 2191 ret = -ENXIO;
@@ -2240,13 +2241,13 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
2240 if (!ret) ret = -EAGAIN; 2241 if (!ret) ret = -EAGAIN;
2241 goto out; 2242 goto out;
2242 } 2243 }
2243 up(&state->sem); 2244 mutex_unlock(&state->sem);
2244 schedule(); 2245 schedule();
2245 if (signal_pending(current)) { 2246 if (signal_pending(current)) {
2246 if(!ret) ret = -ERESTARTSYS; 2247 if(!ret) ret = -ERESTARTSYS;
2247 goto out; 2248 goto out;
2248 } 2249 }
2249 down(&state->sem); 2250 mutex_lock(&state->sem);
2250 if (dmabuf->mapped) 2251 if (dmabuf->mapped)
2251 { 2252 {
2252 if(!ret) 2253 if(!ret)
@@ -2278,7 +2279,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
2278 start_dac(state); 2279 start_dac(state);
2279 } 2280 }
2280out: 2281out:
2281 up(&state->sem); 2282 mutex_unlock(&state->sem);
2282 remove_wait_queue(&state->dmabuf.wait, &wait); 2283 remove_wait_queue(&state->dmabuf.wait, &wait);
2283 set_current_state(TASK_RUNNING); 2284 set_current_state(TASK_RUNNING);
2284 2285
@@ -2411,7 +2412,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma)
2411 goto out; 2412 goto out;
2412 } 2413 }
2413 2414
2414 down(&state->sem); 2415 mutex_lock(&state->sem);
2415 dmabuf = &state->dmabuf; 2416 dmabuf = &state->dmabuf;
2416 if (cs4x_pgoff(vma) != 0) 2417 if (cs4x_pgoff(vma) != 0)
2417 { 2418 {
@@ -2438,7 +2439,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma)
2438 2439
2439 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") ); 2440 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") );
2440out: 2441out:
2441 up(&state->sem); 2442 mutex_unlock(&state->sem);
2442 return ret; 2443 return ret;
2443} 2444}
2444 2445
@@ -3200,7 +3201,7 @@ static int cs_open(struct inode *inode, struct file *file)
3200 if (state == NULL) 3201 if (state == NULL)
3201 return -ENOMEM; 3202 return -ENOMEM;
3202 memset(state, 0, sizeof(struct cs_state)); 3203 memset(state, 0, sizeof(struct cs_state));
3203 init_MUTEX(&state->sem); 3204 mutex_init(&state->sem);
3204 dmabuf = &state->dmabuf; 3205 dmabuf = &state->dmabuf;
3205 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 3206 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
3206 if(dmabuf->pbuf==NULL) 3207 if(dmabuf->pbuf==NULL)
@@ -3241,10 +3242,10 @@ static int cs_open(struct inode *inode, struct file *file)
3241 state->virt = 0; 3242 state->virt = 0;
3242 state->magic = CS_STATE_MAGIC; 3243 state->magic = CS_STATE_MAGIC;
3243 init_waitqueue_head(&dmabuf->wait); 3244 init_waitqueue_head(&dmabuf->wait);
3244 init_MUTEX(&state->open_sem); 3245 mutex_init(&state->open_mutex);
3245 file->private_data = card; 3246 file->private_data = card;
3246 3247
3247 down(&state->open_sem); 3248 mutex_lock(&state->open_mutex);
3248 3249
3249 /* set default sample format. According to OSS Programmer's Guide /dev/dsp 3250 /* set default sample format. According to OSS Programmer's Guide /dev/dsp
3250 should be default to unsigned 8-bits, mono, with sample rate 8kHz and 3251 should be default to unsigned 8-bits, mono, with sample rate 8kHz and
@@ -3260,7 +3261,7 @@ static int cs_open(struct inode *inode, struct file *file)
3260 cs_set_divisor(dmabuf); 3261 cs_set_divisor(dmabuf);
3261 3262
3262 state->open_mode |= FMODE_READ; 3263 state->open_mode |= FMODE_READ;
3263 up(&state->open_sem); 3264 mutex_unlock(&state->open_mutex);
3264 } 3265 }
3265 if(file->f_mode & FMODE_WRITE) 3266 if(file->f_mode & FMODE_WRITE)
3266 { 3267 {
@@ -3271,7 +3272,7 @@ static int cs_open(struct inode *inode, struct file *file)
3271 if (state == NULL) 3272 if (state == NULL)
3272 return -ENOMEM; 3273 return -ENOMEM;
3273 memset(state, 0, sizeof(struct cs_state)); 3274 memset(state, 0, sizeof(struct cs_state));
3274 init_MUTEX(&state->sem); 3275 mutex_init(&state->sem);
3275 dmabuf = &state->dmabuf; 3276 dmabuf = &state->dmabuf;
3276 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 3277 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
3277 if(dmabuf->pbuf==NULL) 3278 if(dmabuf->pbuf==NULL)
@@ -3312,10 +3313,10 @@ static int cs_open(struct inode *inode, struct file *file)
3312 state->virt = 1; 3313 state->virt = 1;
3313 state->magic = CS_STATE_MAGIC; 3314 state->magic = CS_STATE_MAGIC;
3314 init_waitqueue_head(&dmabuf->wait); 3315 init_waitqueue_head(&dmabuf->wait);
3315 init_MUTEX(&state->open_sem); 3316 mutex_init(&state->open_mutex);
3316 file->private_data = card; 3317 file->private_data = card;
3317 3318
3318 down(&state->open_sem); 3319 mutex_lock(&state->open_mutex);
3319 3320
3320 /* set default sample format. According to OSS Programmer's Guide /dev/dsp 3321 /* set default sample format. According to OSS Programmer's Guide /dev/dsp
3321 should be default to unsigned 8-bits, mono, with sample rate 8kHz and 3322 should be default to unsigned 8-bits, mono, with sample rate 8kHz and
@@ -3331,7 +3332,7 @@ static int cs_open(struct inode *inode, struct file *file)
3331 cs_set_divisor(dmabuf); 3332 cs_set_divisor(dmabuf);
3332 3333
3333 state->open_mode |= FMODE_WRITE; 3334 state->open_mode |= FMODE_WRITE;
3334 up(&state->open_sem); 3335 mutex_unlock(&state->open_mutex);
3335 if((ret = prog_dmabuf(state))) 3336 if((ret = prog_dmabuf(state)))
3336 return ret; 3337 return ret;
3337 } 3338 }
@@ -3363,14 +3364,14 @@ static int cs_release(struct inode *inode, struct file *file)
3363 cs_clear_tail(state); 3364 cs_clear_tail(state);
3364 drain_dac(state, file->f_flags & O_NONBLOCK); 3365 drain_dac(state, file->f_flags & O_NONBLOCK);
3365 /* stop DMA state machine and free DMA buffers/channels */ 3366 /* stop DMA state machine and free DMA buffers/channels */
3366 down(&state->open_sem); 3367 mutex_lock(&state->open_mutex);
3367 stop_dac(state); 3368 stop_dac(state);
3368 dealloc_dmabuf(state); 3369 dealloc_dmabuf(state);
3369 state->card->free_pcm_channel(state->card, dmabuf->channel->num); 3370 state->card->free_pcm_channel(state->card, dmabuf->channel->num);
3370 free_page((unsigned long)state->dmabuf.pbuf); 3371 free_page((unsigned long)state->dmabuf.pbuf);
3371 3372
3372 /* we're covered by the open_sem */ 3373 /* we're covered by the open_mutex */
3373 up(&state->open_sem); 3374 mutex_unlock(&state->open_mutex);
3374 state->card->states[state->virt] = NULL; 3375 state->card->states[state->virt] = NULL;
3375 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 3376 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3376 3377
@@ -3395,14 +3396,14 @@ static int cs_release(struct inode *inode, struct file *file)
3395 { 3396 {
3396 CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n") ); 3397 CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n") );
3397 dmabuf = &state->dmabuf; 3398 dmabuf = &state->dmabuf;
3398 down(&state->open_sem); 3399 mutex_lock(&state->open_mutex);
3399 stop_adc(state); 3400 stop_adc(state);
3400 dealloc_dmabuf(state); 3401 dealloc_dmabuf(state);
3401 state->card->free_pcm_channel(state->card, dmabuf->channel->num); 3402 state->card->free_pcm_channel(state->card, dmabuf->channel->num);
3402 free_page((unsigned long)state->dmabuf.pbuf); 3403 free_page((unsigned long)state->dmabuf.pbuf);
3403 3404
3404 /* we're covered by the open_sem */ 3405 /* we're covered by the open_mutex */
3405 up(&state->open_sem); 3406 mutex_unlock(&state->open_mutex);
3406 state->card->states[state->virt] = NULL; 3407 state->card->states[state->virt] = NULL;
3407 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 3408 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3408 3409
@@ -5507,7 +5508,7 @@ static int __devinit cs46xx_probe(struct pci_dev *pci_dev,
5507 } 5508 }
5508 5509
5509 init_waitqueue_head(&card->midi.open_wait); 5510 init_waitqueue_head(&card->midi.open_wait);
5510 init_MUTEX(&card->midi.open_sem); 5511 mutex_init(&card->midi.open_mutex);
5511 init_waitqueue_head(&card->midi.iwait); 5512 init_waitqueue_head(&card->midi.iwait);
5512 init_waitqueue_head(&card->midi.owait); 5513 init_waitqueue_head(&card->midi.owait);
5513 cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST); 5514 cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST);
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c
index ae55c536613a..094f569cc6e0 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -157,6 +157,7 @@
157#include <linux/gameport.h> 157#include <linux/gameport.h>
158#include <linux/wait.h> 158#include <linux/wait.h>
159#include <linux/dma-mapping.h> 159#include <linux/dma-mapping.h>
160#include <linux/mutex.h>
160 161
161#include <asm/io.h> 162#include <asm/io.h>
162#include <asm/page.h> 163#include <asm/page.h>
@@ -346,7 +347,7 @@ struct es1370_state {
346 unsigned sctrl; 347 unsigned sctrl;
347 348
348 spinlock_t lock; 349 spinlock_t lock;
349 struct semaphore open_sem; 350 struct mutex open_mutex;
350 mode_t open_mode; 351 mode_t open_mode;
351 wait_queue_head_t open_wait; 352 wait_queue_head_t open_wait;
352 353
@@ -393,7 +394,7 @@ struct es1370_state {
393 struct gameport *gameport; 394 struct gameport *gameport;
394#endif 395#endif
395 396
396 struct semaphore sem; 397 struct mutex mutex;
397}; 398};
398 399
399/* --------------------------------------------------------------------- */ 400/* --------------------------------------------------------------------- */
@@ -1159,7 +1160,7 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
1159 return -ENXIO; 1160 return -ENXIO;
1160 if (!access_ok(VERIFY_WRITE, buffer, count)) 1161 if (!access_ok(VERIFY_WRITE, buffer, count))
1161 return -EFAULT; 1162 return -EFAULT;
1162 down(&s->sem); 1163 mutex_lock(&s->mutex);
1163 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) 1164 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
1164 goto out; 1165 goto out;
1165 1166
@@ -1183,14 +1184,14 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
1183 ret = -EAGAIN; 1184 ret = -EAGAIN;
1184 goto out; 1185 goto out;
1185 } 1186 }
1186 up(&s->sem); 1187 mutex_unlock(&s->mutex);
1187 schedule(); 1188 schedule();
1188 if (signal_pending(current)) { 1189 if (signal_pending(current)) {
1189 if (!ret) 1190 if (!ret)
1190 ret = -ERESTARTSYS; 1191 ret = -ERESTARTSYS;
1191 goto out; 1192 goto out;
1192 } 1193 }
1193 down(&s->sem); 1194 mutex_lock(&s->mutex);
1194 if (s->dma_adc.mapped) 1195 if (s->dma_adc.mapped)
1195 { 1196 {
1196 ret = -ENXIO; 1197 ret = -ENXIO;
@@ -1215,7 +1216,7 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
1215 start_adc(s); 1216 start_adc(s);
1216 } 1217 }
1217out: 1218out:
1218 up(&s->sem); 1219 mutex_unlock(&s->mutex);
1219 remove_wait_queue(&s->dma_adc.wait, &wait); 1220 remove_wait_queue(&s->dma_adc.wait, &wait);
1220 set_current_state(TASK_RUNNING); 1221 set_current_state(TASK_RUNNING);
1221 return ret; 1222 return ret;
@@ -1235,7 +1236,7 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
1235 return -ENXIO; 1236 return -ENXIO;
1236 if (!access_ok(VERIFY_READ, buffer, count)) 1237 if (!access_ok(VERIFY_READ, buffer, count))
1237 return -EFAULT; 1238 return -EFAULT;
1238 down(&s->sem); 1239 mutex_lock(&s->mutex);
1239 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) 1240 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s)))
1240 goto out; 1241 goto out;
1241 ret = 0; 1242 ret = 0;
@@ -1263,14 +1264,14 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
1263 ret = -EAGAIN; 1264 ret = -EAGAIN;
1264 goto out; 1265 goto out;
1265 } 1266 }
1266 up(&s->sem); 1267 mutex_unlock(&s->mutex);
1267 schedule(); 1268 schedule();
1268 if (signal_pending(current)) { 1269 if (signal_pending(current)) {
1269 if (!ret) 1270 if (!ret)
1270 ret = -ERESTARTSYS; 1271 ret = -ERESTARTSYS;
1271 goto out; 1272 goto out;
1272 } 1273 }
1273 down(&s->sem); 1274 mutex_lock(&s->mutex);
1274 if (s->dma_dac2.mapped) 1275 if (s->dma_dac2.mapped)
1275 { 1276 {
1276 ret = -ENXIO; 1277 ret = -ENXIO;
@@ -1296,7 +1297,7 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
1296 start_dac2(s); 1297 start_dac2(s);
1297 } 1298 }
1298out: 1299out:
1299 up(&s->sem); 1300 mutex_unlock(&s->mutex);
1300 remove_wait_queue(&s->dma_dac2.wait, &wait); 1301 remove_wait_queue(&s->dma_dac2.wait, &wait);
1301 set_current_state(TASK_RUNNING); 1302 set_current_state(TASK_RUNNING);
1302 return ret; 1303 return ret;
@@ -1348,7 +1349,7 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
1348 1349
1349 VALIDATE_STATE(s); 1350 VALIDATE_STATE(s);
1350 lock_kernel(); 1351 lock_kernel();
1351 down(&s->sem); 1352 mutex_lock(&s->mutex);
1352 if (vma->vm_flags & VM_WRITE) { 1353 if (vma->vm_flags & VM_WRITE) {
1353 if ((ret = prog_dmabuf_dac2(s)) != 0) { 1354 if ((ret = prog_dmabuf_dac2(s)) != 0) {
1354 goto out; 1355 goto out;
@@ -1380,7 +1381,7 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
1380 } 1381 }
1381 db->mapped = 1; 1382 db->mapped = 1;
1382out: 1383out:
1383 up(&s->sem); 1384 mutex_unlock(&s->mutex);
1384 unlock_kernel(); 1385 unlock_kernel();
1385 return ret; 1386 return ret;
1386} 1387}
@@ -1752,21 +1753,21 @@ static int es1370_open(struct inode *inode, struct file *file)
1752 VALIDATE_STATE(s); 1753 VALIDATE_STATE(s);
1753 file->private_data = s; 1754 file->private_data = s;
1754 /* wait for device to become free */ 1755 /* wait for device to become free */
1755 down(&s->open_sem); 1756 mutex_lock(&s->open_mutex);
1756 while (s->open_mode & file->f_mode) { 1757 while (s->open_mode & file->f_mode) {
1757 if (file->f_flags & O_NONBLOCK) { 1758 if (file->f_flags & O_NONBLOCK) {
1758 up(&s->open_sem); 1759 mutex_unlock(&s->open_mutex);
1759 return -EBUSY; 1760 return -EBUSY;
1760 } 1761 }
1761 add_wait_queue(&s->open_wait, &wait); 1762 add_wait_queue(&s->open_wait, &wait);
1762 __set_current_state(TASK_INTERRUPTIBLE); 1763 __set_current_state(TASK_INTERRUPTIBLE);
1763 up(&s->open_sem); 1764 mutex_unlock(&s->open_mutex);
1764 schedule(); 1765 schedule();
1765 remove_wait_queue(&s->open_wait, &wait); 1766 remove_wait_queue(&s->open_wait, &wait);
1766 set_current_state(TASK_RUNNING); 1767 set_current_state(TASK_RUNNING);
1767 if (signal_pending(current)) 1768 if (signal_pending(current))
1768 return -ERESTARTSYS; 1769 return -ERESTARTSYS;
1769 down(&s->open_sem); 1770 mutex_lock(&s->open_mutex);
1770 } 1771 }
1771 spin_lock_irqsave(&s->lock, flags); 1772 spin_lock_irqsave(&s->lock, flags);
1772 if (!(s->open_mode & (FMODE_READ|FMODE_WRITE))) 1773 if (!(s->open_mode & (FMODE_READ|FMODE_WRITE)))
@@ -1793,8 +1794,8 @@ static int es1370_open(struct inode *inode, struct file *file)
1793 outl(s->ctrl, s->io+ES1370_REG_CONTROL); 1794 outl(s->ctrl, s->io+ES1370_REG_CONTROL);
1794 spin_unlock_irqrestore(&s->lock, flags); 1795 spin_unlock_irqrestore(&s->lock, flags);
1795 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1796 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1796 up(&s->open_sem); 1797 mutex_unlock(&s->open_mutex);
1797 init_MUTEX(&s->sem); 1798 mutex_init(&s->mutex);
1798 return nonseekable_open(inode, file); 1799 return nonseekable_open(inode, file);
1799} 1800}
1800 1801
@@ -1806,7 +1807,7 @@ static int es1370_release(struct inode *inode, struct file *file)
1806 lock_kernel(); 1807 lock_kernel();
1807 if (file->f_mode & FMODE_WRITE) 1808 if (file->f_mode & FMODE_WRITE)
1808 drain_dac2(s, file->f_flags & O_NONBLOCK); 1809 drain_dac2(s, file->f_flags & O_NONBLOCK);
1809 down(&s->open_sem); 1810 mutex_lock(&s->open_mutex);
1810 if (file->f_mode & FMODE_WRITE) { 1811 if (file->f_mode & FMODE_WRITE) {
1811 stop_dac2(s); 1812 stop_dac2(s);
1812 synchronize_irq(s->irq); 1813 synchronize_irq(s->irq);
@@ -1818,7 +1819,7 @@ static int es1370_release(struct inode *inode, struct file *file)
1818 } 1819 }
1819 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 1820 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
1820 wake_up(&s->open_wait); 1821 wake_up(&s->open_wait);
1821 up(&s->open_sem); 1822 mutex_unlock(&s->open_mutex);
1822 unlock_kernel(); 1823 unlock_kernel();
1823 return 0; 1824 return 0;
1824} 1825}
@@ -2198,21 +2199,21 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
2198 return -EINVAL; 2199 return -EINVAL;
2199 file->private_data = s; 2200 file->private_data = s;
2200 /* wait for device to become free */ 2201 /* wait for device to become free */
2201 down(&s->open_sem); 2202 mutex_lock(&s->open_mutex);
2202 while (s->open_mode & FMODE_DAC) { 2203 while (s->open_mode & FMODE_DAC) {
2203 if (file->f_flags & O_NONBLOCK) { 2204 if (file->f_flags & O_NONBLOCK) {
2204 up(&s->open_sem); 2205 mutex_unlock(&s->open_mutex);
2205 return -EBUSY; 2206 return -EBUSY;
2206 } 2207 }
2207 add_wait_queue(&s->open_wait, &wait); 2208 add_wait_queue(&s->open_wait, &wait);
2208 __set_current_state(TASK_INTERRUPTIBLE); 2209 __set_current_state(TASK_INTERRUPTIBLE);
2209 up(&s->open_sem); 2210 mutex_unlock(&s->open_mutex);
2210 schedule(); 2211 schedule();
2211 remove_wait_queue(&s->open_wait, &wait); 2212 remove_wait_queue(&s->open_wait, &wait);
2212 set_current_state(TASK_RUNNING); 2213 set_current_state(TASK_RUNNING);
2213 if (signal_pending(current)) 2214 if (signal_pending(current))
2214 return -ERESTARTSYS; 2215 return -ERESTARTSYS;
2215 down(&s->open_sem); 2216 mutex_lock(&s->open_mutex);
2216 } 2217 }
2217 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0; 2218 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0;
2218 s->dma_dac1.enabled = 1; 2219 s->dma_dac1.enabled = 1;
@@ -2227,7 +2228,7 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
2227 outl(s->ctrl, s->io+ES1370_REG_CONTROL); 2228 outl(s->ctrl, s->io+ES1370_REG_CONTROL);
2228 spin_unlock_irqrestore(&s->lock, flags); 2229 spin_unlock_irqrestore(&s->lock, flags);
2229 s->open_mode |= FMODE_DAC; 2230 s->open_mode |= FMODE_DAC;
2230 up(&s->open_sem); 2231 mutex_unlock(&s->open_mutex);
2231 return nonseekable_open(inode, file); 2232 return nonseekable_open(inode, file);
2232} 2233}
2233 2234
@@ -2238,12 +2239,12 @@ static int es1370_release_dac(struct inode *inode, struct file *file)
2238 VALIDATE_STATE(s); 2239 VALIDATE_STATE(s);
2239 lock_kernel(); 2240 lock_kernel();
2240 drain_dac1(s, file->f_flags & O_NONBLOCK); 2241 drain_dac1(s, file->f_flags & O_NONBLOCK);
2241 down(&s->open_sem); 2242 mutex_lock(&s->open_mutex);
2242 stop_dac1(s); 2243 stop_dac1(s);
2243 dealloc_dmabuf(s, &s->dma_dac1); 2244 dealloc_dmabuf(s, &s->dma_dac1);
2244 s->open_mode &= ~FMODE_DAC; 2245 s->open_mode &= ~FMODE_DAC;
2245 wake_up(&s->open_wait); 2246 wake_up(&s->open_wait);
2246 up(&s->open_sem); 2247 mutex_unlock(&s->open_mutex);
2247 unlock_kernel(); 2248 unlock_kernel();
2248 return 0; 2249 return 0;
2249} 2250}
@@ -2430,21 +2431,21 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
2430 VALIDATE_STATE(s); 2431 VALIDATE_STATE(s);
2431 file->private_data = s; 2432 file->private_data = s;
2432 /* wait for device to become free */ 2433 /* wait for device to become free */
2433 down(&s->open_sem); 2434 mutex_lock(&s->open_mutex);
2434 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 2435 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
2435 if (file->f_flags & O_NONBLOCK) { 2436 if (file->f_flags & O_NONBLOCK) {
2436 up(&s->open_sem); 2437 mutex_unlock(&s->open_mutex);
2437 return -EBUSY; 2438 return -EBUSY;
2438 } 2439 }
2439 add_wait_queue(&s->open_wait, &wait); 2440 add_wait_queue(&s->open_wait, &wait);
2440 __set_current_state(TASK_INTERRUPTIBLE); 2441 __set_current_state(TASK_INTERRUPTIBLE);
2441 up(&s->open_sem); 2442 mutex_unlock(&s->open_mutex);
2442 schedule(); 2443 schedule();
2443 remove_wait_queue(&s->open_wait, &wait); 2444 remove_wait_queue(&s->open_wait, &wait);
2444 set_current_state(TASK_RUNNING); 2445 set_current_state(TASK_RUNNING);
2445 if (signal_pending(current)) 2446 if (signal_pending(current))
2446 return -ERESTARTSYS; 2447 return -ERESTARTSYS;
2447 down(&s->open_sem); 2448 mutex_lock(&s->open_mutex);
2448 } 2449 }
2449 spin_lock_irqsave(&s->lock, flags); 2450 spin_lock_irqsave(&s->lock, flags);
2450 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2451 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2465,7 +2466,7 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
2465 es1370_handle_midi(s); 2466 es1370_handle_midi(s);
2466 spin_unlock_irqrestore(&s->lock, flags); 2467 spin_unlock_irqrestore(&s->lock, flags);
2467 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 2468 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
2468 up(&s->open_sem); 2469 mutex_unlock(&s->open_mutex);
2469 return nonseekable_open(inode, file); 2470 return nonseekable_open(inode, file);
2470} 2471}
2471 2472
@@ -2499,7 +2500,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file)
2499 remove_wait_queue(&s->midi.owait, &wait); 2500 remove_wait_queue(&s->midi.owait, &wait);
2500 set_current_state(TASK_RUNNING); 2501 set_current_state(TASK_RUNNING);
2501 } 2502 }
2502 down(&s->open_sem); 2503 mutex_lock(&s->open_mutex);
2503 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 2504 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
2504 spin_lock_irqsave(&s->lock, flags); 2505 spin_lock_irqsave(&s->lock, flags);
2505 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2506 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2508,7 +2509,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file)
2508 } 2509 }
2509 spin_unlock_irqrestore(&s->lock, flags); 2510 spin_unlock_irqrestore(&s->lock, flags);
2510 wake_up(&s->open_wait); 2511 wake_up(&s->open_wait);
2511 up(&s->open_sem); 2512 mutex_unlock(&s->open_mutex);
2512 unlock_kernel(); 2513 unlock_kernel();
2513 return 0; 2514 return 0;
2514} 2515}
@@ -2638,7 +2639,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2638 init_waitqueue_head(&s->open_wait); 2639 init_waitqueue_head(&s->open_wait);
2639 init_waitqueue_head(&s->midi.iwait); 2640 init_waitqueue_head(&s->midi.iwait);
2640 init_waitqueue_head(&s->midi.owait); 2641 init_waitqueue_head(&s->midi.owait);
2641 init_MUTEX(&s->open_sem); 2642 mutex_init(&s->open_mutex);
2642 spin_lock_init(&s->lock); 2643 spin_lock_init(&s->lock);
2643 s->magic = ES1370_MAGIC; 2644 s->magic = ES1370_MAGIC;
2644 s->dev = pcidev; 2645 s->dev = pcidev;
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index 5c697f162579..4400c8538686 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -129,6 +129,7 @@
129#include <linux/gameport.h> 129#include <linux/gameport.h>
130#include <linux/wait.h> 130#include <linux/wait.h>
131#include <linux/dma-mapping.h> 131#include <linux/dma-mapping.h>
132#include <linux/mutex.h>
132 133
133#include <asm/io.h> 134#include <asm/io.h>
134#include <asm/page.h> 135#include <asm/page.h>
@@ -419,7 +420,7 @@ struct es1371_state {
419 unsigned dac1rate, dac2rate, adcrate; 420 unsigned dac1rate, dac2rate, adcrate;
420 421
421 spinlock_t lock; 422 spinlock_t lock;
422 struct semaphore open_sem; 423 struct mutex open_mutex;
423 mode_t open_mode; 424 mode_t open_mode;
424 wait_queue_head_t open_wait; 425 wait_queue_head_t open_wait;
425 426
@@ -462,7 +463,7 @@ struct es1371_state {
462 struct gameport *gameport; 463 struct gameport *gameport;
463#endif 464#endif
464 465
465 struct semaphore sem; 466 struct mutex sem;
466}; 467};
467 468
468/* --------------------------------------------------------------------- */ 469/* --------------------------------------------------------------------- */
@@ -1346,7 +1347,7 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
1346 return -ENXIO; 1347 return -ENXIO;
1347 if (!access_ok(VERIFY_WRITE, buffer, count)) 1348 if (!access_ok(VERIFY_WRITE, buffer, count))
1348 return -EFAULT; 1349 return -EFAULT;
1349 down(&s->sem); 1350 mutex_lock(&s->sem);
1350 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s))) 1351 if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
1351 goto out2; 1352 goto out2;
1352 1353
@@ -1370,14 +1371,14 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
1370 ret = -EAGAIN; 1371 ret = -EAGAIN;
1371 goto out; 1372 goto out;
1372 } 1373 }
1373 up(&s->sem); 1374 mutex_unlock(&s->sem);
1374 schedule(); 1375 schedule();
1375 if (signal_pending(current)) { 1376 if (signal_pending(current)) {
1376 if (!ret) 1377 if (!ret)
1377 ret = -ERESTARTSYS; 1378 ret = -ERESTARTSYS;
1378 goto out2; 1379 goto out2;
1379 } 1380 }
1380 down(&s->sem); 1381 mutex_lock(&s->sem);
1381 if (s->dma_adc.mapped) 1382 if (s->dma_adc.mapped)
1382 { 1383 {
1383 ret = -ENXIO; 1384 ret = -ENXIO;
@@ -1402,7 +1403,7 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
1402 start_adc(s); 1403 start_adc(s);
1403 } 1404 }
1404out: 1405out:
1405 up(&s->sem); 1406 mutex_unlock(&s->sem);
1406out2: 1407out2:
1407 remove_wait_queue(&s->dma_adc.wait, &wait); 1408 remove_wait_queue(&s->dma_adc.wait, &wait);
1408 set_current_state(TASK_RUNNING); 1409 set_current_state(TASK_RUNNING);
@@ -1423,7 +1424,7 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
1423 return -ENXIO; 1424 return -ENXIO;
1424 if (!access_ok(VERIFY_READ, buffer, count)) 1425 if (!access_ok(VERIFY_READ, buffer, count))
1425 return -EFAULT; 1426 return -EFAULT;
1426 down(&s->sem); 1427 mutex_lock(&s->sem);
1427 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s))) 1428 if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s)))
1428 goto out3; 1429 goto out3;
1429 ret = 0; 1430 ret = 0;
@@ -1451,14 +1452,14 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
1451 ret = -EAGAIN; 1452 ret = -EAGAIN;
1452 goto out; 1453 goto out;
1453 } 1454 }
1454 up(&s->sem); 1455 mutex_unlock(&s->sem);
1455 schedule(); 1456 schedule();
1456 if (signal_pending(current)) { 1457 if (signal_pending(current)) {
1457 if (!ret) 1458 if (!ret)
1458 ret = -ERESTARTSYS; 1459 ret = -ERESTARTSYS;
1459 goto out2; 1460 goto out2;
1460 } 1461 }
1461 down(&s->sem); 1462 mutex_lock(&s->sem);
1462 if (s->dma_dac2.mapped) 1463 if (s->dma_dac2.mapped)
1463 { 1464 {
1464 ret = -ENXIO; 1465 ret = -ENXIO;
@@ -1484,7 +1485,7 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
1484 start_dac2(s); 1485 start_dac2(s);
1485 } 1486 }
1486out: 1487out:
1487 up(&s->sem); 1488 mutex_unlock(&s->sem);
1488out2: 1489out2:
1489 remove_wait_queue(&s->dma_dac2.wait, &wait); 1490 remove_wait_queue(&s->dma_dac2.wait, &wait);
1490out3: 1491out3:
@@ -1538,7 +1539,7 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma)
1538 1539
1539 VALIDATE_STATE(s); 1540 VALIDATE_STATE(s);
1540 lock_kernel(); 1541 lock_kernel();
1541 down(&s->sem); 1542 mutex_lock(&s->sem);
1542 1543
1543 if (vma->vm_flags & VM_WRITE) { 1544 if (vma->vm_flags & VM_WRITE) {
1544 if ((ret = prog_dmabuf_dac2(s)) != 0) { 1545 if ((ret = prog_dmabuf_dac2(s)) != 0) {
@@ -1571,7 +1572,7 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma)
1571 } 1572 }
1572 db->mapped = 1; 1573 db->mapped = 1;
1573out: 1574out:
1574 up(&s->sem); 1575 mutex_unlock(&s->sem);
1575 unlock_kernel(); 1576 unlock_kernel();
1576 return ret; 1577 return ret;
1577} 1578}
@@ -1938,21 +1939,21 @@ static int es1371_open(struct inode *inode, struct file *file)
1938 VALIDATE_STATE(s); 1939 VALIDATE_STATE(s);
1939 file->private_data = s; 1940 file->private_data = s;
1940 /* wait for device to become free */ 1941 /* wait for device to become free */
1941 down(&s->open_sem); 1942 mutex_lock(&s->open_mutex);
1942 while (s->open_mode & file->f_mode) { 1943 while (s->open_mode & file->f_mode) {
1943 if (file->f_flags & O_NONBLOCK) { 1944 if (file->f_flags & O_NONBLOCK) {
1944 up(&s->open_sem); 1945 mutex_unlock(&s->open_mutex);
1945 return -EBUSY; 1946 return -EBUSY;
1946 } 1947 }
1947 add_wait_queue(&s->open_wait, &wait); 1948 add_wait_queue(&s->open_wait, &wait);
1948 __set_current_state(TASK_INTERRUPTIBLE); 1949 __set_current_state(TASK_INTERRUPTIBLE);
1949 up(&s->open_sem); 1950 mutex_unlock(&s->open_mutex);
1950 schedule(); 1951 schedule();
1951 remove_wait_queue(&s->open_wait, &wait); 1952 remove_wait_queue(&s->open_wait, &wait);
1952 set_current_state(TASK_RUNNING); 1953 set_current_state(TASK_RUNNING);
1953 if (signal_pending(current)) 1954 if (signal_pending(current))
1954 return -ERESTARTSYS; 1955 return -ERESTARTSYS;
1955 down(&s->open_sem); 1956 mutex_lock(&s->open_mutex);
1956 } 1957 }
1957 if (file->f_mode & FMODE_READ) { 1958 if (file->f_mode & FMODE_READ) {
1958 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.subdivision = 0; 1959 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.subdivision = 0;
@@ -1982,8 +1983,8 @@ static int es1371_open(struct inode *inode, struct file *file)
1982 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); 1983 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
1983 spin_unlock_irqrestore(&s->lock, flags); 1984 spin_unlock_irqrestore(&s->lock, flags);
1984 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1985 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1985 up(&s->open_sem); 1986 mutex_unlock(&s->open_mutex);
1986 init_MUTEX(&s->sem); 1987 mutex_init(&s->sem);
1987 return nonseekable_open(inode, file); 1988 return nonseekable_open(inode, file);
1988} 1989}
1989 1990
@@ -1995,7 +1996,7 @@ static int es1371_release(struct inode *inode, struct file *file)
1995 lock_kernel(); 1996 lock_kernel();
1996 if (file->f_mode & FMODE_WRITE) 1997 if (file->f_mode & FMODE_WRITE)
1997 drain_dac2(s, file->f_flags & O_NONBLOCK); 1998 drain_dac2(s, file->f_flags & O_NONBLOCK);
1998 down(&s->open_sem); 1999 mutex_lock(&s->open_mutex);
1999 if (file->f_mode & FMODE_WRITE) { 2000 if (file->f_mode & FMODE_WRITE) {
2000 stop_dac2(s); 2001 stop_dac2(s);
2001 dealloc_dmabuf(s, &s->dma_dac2); 2002 dealloc_dmabuf(s, &s->dma_dac2);
@@ -2005,7 +2006,7 @@ static int es1371_release(struct inode *inode, struct file *file)
2005 dealloc_dmabuf(s, &s->dma_adc); 2006 dealloc_dmabuf(s, &s->dma_adc);
2006 } 2007 }
2007 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 2008 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
2008 up(&s->open_sem); 2009 mutex_unlock(&s->open_mutex);
2009 wake_up(&s->open_wait); 2010 wake_up(&s->open_wait);
2010 unlock_kernel(); 2011 unlock_kernel();
2011 return 0; 2012 return 0;
@@ -2377,21 +2378,21 @@ static int es1371_open_dac(struct inode *inode, struct file *file)
2377 return -EINVAL; 2378 return -EINVAL;
2378 file->private_data = s; 2379 file->private_data = s;
2379 /* wait for device to become free */ 2380 /* wait for device to become free */
2380 down(&s->open_sem); 2381 mutex_lock(&s->open_mutex);
2381 while (s->open_mode & FMODE_DAC) { 2382 while (s->open_mode & FMODE_DAC) {
2382 if (file->f_flags & O_NONBLOCK) { 2383 if (file->f_flags & O_NONBLOCK) {
2383 up(&s->open_sem); 2384 mutex_unlock(&s->open_mutex);
2384 return -EBUSY; 2385 return -EBUSY;
2385 } 2386 }
2386 add_wait_queue(&s->open_wait, &wait); 2387 add_wait_queue(&s->open_wait, &wait);
2387 __set_current_state(TASK_INTERRUPTIBLE); 2388 __set_current_state(TASK_INTERRUPTIBLE);
2388 up(&s->open_sem); 2389 mutex_unlock(&s->open_mutex);
2389 schedule(); 2390 schedule();
2390 remove_wait_queue(&s->open_wait, &wait); 2391 remove_wait_queue(&s->open_wait, &wait);
2391 set_current_state(TASK_RUNNING); 2392 set_current_state(TASK_RUNNING);
2392 if (signal_pending(current)) 2393 if (signal_pending(current))
2393 return -ERESTARTSYS; 2394 return -ERESTARTSYS;
2394 down(&s->open_sem); 2395 mutex_lock(&s->open_mutex);
2395 } 2396 }
2396 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0; 2397 s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0;
2397 s->dma_dac1.enabled = 1; 2398 s->dma_dac1.enabled = 1;
@@ -2405,7 +2406,7 @@ static int es1371_open_dac(struct inode *inode, struct file *file)
2405 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL); 2406 outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
2406 spin_unlock_irqrestore(&s->lock, flags); 2407 spin_unlock_irqrestore(&s->lock, flags);
2407 s->open_mode |= FMODE_DAC; 2408 s->open_mode |= FMODE_DAC;
2408 up(&s->open_sem); 2409 mutex_unlock(&s->open_mutex);
2409 return nonseekable_open(inode, file); 2410 return nonseekable_open(inode, file);
2410} 2411}
2411 2412
@@ -2416,11 +2417,11 @@ static int es1371_release_dac(struct inode *inode, struct file *file)
2416 VALIDATE_STATE(s); 2417 VALIDATE_STATE(s);
2417 lock_kernel(); 2418 lock_kernel();
2418 drain_dac1(s, file->f_flags & O_NONBLOCK); 2419 drain_dac1(s, file->f_flags & O_NONBLOCK);
2419 down(&s->open_sem); 2420 mutex_lock(&s->open_mutex);
2420 stop_dac1(s); 2421 stop_dac1(s);
2421 dealloc_dmabuf(s, &s->dma_dac1); 2422 dealloc_dmabuf(s, &s->dma_dac1);
2422 s->open_mode &= ~FMODE_DAC; 2423 s->open_mode &= ~FMODE_DAC;
2423 up(&s->open_sem); 2424 mutex_unlock(&s->open_mutex);
2424 wake_up(&s->open_wait); 2425 wake_up(&s->open_wait);
2425 unlock_kernel(); 2426 unlock_kernel();
2426 return 0; 2427 return 0;
@@ -2608,21 +2609,21 @@ static int es1371_midi_open(struct inode *inode, struct file *file)
2608 VALIDATE_STATE(s); 2609 VALIDATE_STATE(s);
2609 file->private_data = s; 2610 file->private_data = s;
2610 /* wait for device to become free */ 2611 /* wait for device to become free */
2611 down(&s->open_sem); 2612 mutex_lock(&s->open_mutex);
2612 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 2613 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
2613 if (file->f_flags & O_NONBLOCK) { 2614 if (file->f_flags & O_NONBLOCK) {
2614 up(&s->open_sem); 2615 mutex_unlock(&s->open_mutex);
2615 return -EBUSY; 2616 return -EBUSY;
2616 } 2617 }
2617 add_wait_queue(&s->open_wait, &wait); 2618 add_wait_queue(&s->open_wait, &wait);
2618 __set_current_state(TASK_INTERRUPTIBLE); 2619 __set_current_state(TASK_INTERRUPTIBLE);
2619 up(&s->open_sem); 2620 mutex_unlock(&s->open_mutex);
2620 schedule(); 2621 schedule();
2621 remove_wait_queue(&s->open_wait, &wait); 2622 remove_wait_queue(&s->open_wait, &wait);
2622 set_current_state(TASK_RUNNING); 2623 set_current_state(TASK_RUNNING);
2623 if (signal_pending(current)) 2624 if (signal_pending(current))
2624 return -ERESTARTSYS; 2625 return -ERESTARTSYS;
2625 down(&s->open_sem); 2626 mutex_lock(&s->open_mutex);
2626 } 2627 }
2627 spin_lock_irqsave(&s->lock, flags); 2628 spin_lock_irqsave(&s->lock, flags);
2628 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2629 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2643,7 +2644,7 @@ static int es1371_midi_open(struct inode *inode, struct file *file)
2643 es1371_handle_midi(s); 2644 es1371_handle_midi(s);
2644 spin_unlock_irqrestore(&s->lock, flags); 2645 spin_unlock_irqrestore(&s->lock, flags);
2645 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 2646 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
2646 up(&s->open_sem); 2647 mutex_unlock(&s->open_mutex);
2647 return nonseekable_open(inode, file); 2648 return nonseekable_open(inode, file);
2648} 2649}
2649 2650
@@ -2676,7 +2677,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file)
2676 remove_wait_queue(&s->midi.owait, &wait); 2677 remove_wait_queue(&s->midi.owait, &wait);
2677 set_current_state(TASK_RUNNING); 2678 set_current_state(TASK_RUNNING);
2678 } 2679 }
2679 down(&s->open_sem); 2680 mutex_lock(&s->open_mutex);
2680 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 2681 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
2681 spin_lock_irqsave(&s->lock, flags); 2682 spin_lock_irqsave(&s->lock, flags);
2682 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2683 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2684,7 +2685,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file)
2684 outl(s->ctrl, s->io+ES1371_REG_CONTROL); 2685 outl(s->ctrl, s->io+ES1371_REG_CONTROL);
2685 } 2686 }
2686 spin_unlock_irqrestore(&s->lock, flags); 2687 spin_unlock_irqrestore(&s->lock, flags);
2687 up(&s->open_sem); 2688 mutex_unlock(&s->open_mutex);
2688 wake_up(&s->open_wait); 2689 wake_up(&s->open_wait);
2689 unlock_kernel(); 2690 unlock_kernel();
2690 return 0; 2691 return 0;
@@ -2884,7 +2885,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
2884 init_waitqueue_head(&s->open_wait); 2885 init_waitqueue_head(&s->open_wait);
2885 init_waitqueue_head(&s->midi.iwait); 2886 init_waitqueue_head(&s->midi.iwait);
2886 init_waitqueue_head(&s->midi.owait); 2887 init_waitqueue_head(&s->midi.owait);
2887 init_MUTEX(&s->open_sem); 2888 mutex_init(&s->open_mutex);
2888 spin_lock_init(&s->lock); 2889 spin_lock_init(&s->lock);
2889 s->magic = ES1371_MAGIC; 2890 s->magic = ES1371_MAGIC;
2890 s->dev = pcidev; 2891 s->dev = pcidev;
diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
index 849b59f67ef5..78d3e29ce968 100644
--- a/sound/oss/esssolo1.c
+++ b/sound/oss/esssolo1.c
@@ -105,6 +105,8 @@
105#include <linux/gameport.h> 105#include <linux/gameport.h>
106#include <linux/wait.h> 106#include <linux/wait.h>
107#include <linux/dma-mapping.h> 107#include <linux/dma-mapping.h>
108#include <linux/mutex.h>
109
108 110
109#include <asm/io.h> 111#include <asm/io.h>
110#include <asm/page.h> 112#include <asm/page.h>
@@ -191,7 +193,7 @@ struct solo1_state {
191 unsigned ena; 193 unsigned ena;
192 194
193 spinlock_t lock; 195 spinlock_t lock;
194 struct semaphore open_sem; 196 struct mutex open_mutex;
195 mode_t open_mode; 197 mode_t open_mode;
196 wait_queue_head_t open_wait; 198 wait_queue_head_t open_wait;
197 199
@@ -1581,7 +1583,7 @@ static int solo1_release(struct inode *inode, struct file *file)
1581 lock_kernel(); 1583 lock_kernel();
1582 if (file->f_mode & FMODE_WRITE) 1584 if (file->f_mode & FMODE_WRITE)
1583 drain_dac(s, file->f_flags & O_NONBLOCK); 1585 drain_dac(s, file->f_flags & O_NONBLOCK);
1584 down(&s->open_sem); 1586 mutex_lock(&s->open_mutex);
1585 if (file->f_mode & FMODE_WRITE) { 1587 if (file->f_mode & FMODE_WRITE) {
1586 stop_dac(s); 1588 stop_dac(s);
1587 outb(0, s->iobase+6); /* disable DMA */ 1589 outb(0, s->iobase+6); /* disable DMA */
@@ -1595,7 +1597,7 @@ static int solo1_release(struct inode *inode, struct file *file)
1595 } 1597 }
1596 s->open_mode &= ~(FMODE_READ | FMODE_WRITE); 1598 s->open_mode &= ~(FMODE_READ | FMODE_WRITE);
1597 wake_up(&s->open_wait); 1599 wake_up(&s->open_wait);
1598 up(&s->open_sem); 1600 mutex_unlock(&s->open_mutex);
1599 unlock_kernel(); 1601 unlock_kernel();
1600 return 0; 1602 return 0;
1601} 1603}
@@ -1624,21 +1626,21 @@ static int solo1_open(struct inode *inode, struct file *file)
1624 VALIDATE_STATE(s); 1626 VALIDATE_STATE(s);
1625 file->private_data = s; 1627 file->private_data = s;
1626 /* wait for device to become free */ 1628 /* wait for device to become free */
1627 down(&s->open_sem); 1629 mutex_lock(&s->open_mutex);
1628 while (s->open_mode & (FMODE_READ | FMODE_WRITE)) { 1630 while (s->open_mode & (FMODE_READ | FMODE_WRITE)) {
1629 if (file->f_flags & O_NONBLOCK) { 1631 if (file->f_flags & O_NONBLOCK) {
1630 up(&s->open_sem); 1632 mutex_unlock(&s->open_mutex);
1631 return -EBUSY; 1633 return -EBUSY;
1632 } 1634 }
1633 add_wait_queue(&s->open_wait, &wait); 1635 add_wait_queue(&s->open_wait, &wait);
1634 __set_current_state(TASK_INTERRUPTIBLE); 1636 __set_current_state(TASK_INTERRUPTIBLE);
1635 up(&s->open_sem); 1637 mutex_unlock(&s->open_mutex);
1636 schedule(); 1638 schedule();
1637 remove_wait_queue(&s->open_wait, &wait); 1639 remove_wait_queue(&s->open_wait, &wait);
1638 set_current_state(TASK_RUNNING); 1640 set_current_state(TASK_RUNNING);
1639 if (signal_pending(current)) 1641 if (signal_pending(current))
1640 return -ERESTARTSYS; 1642 return -ERESTARTSYS;
1641 down(&s->open_sem); 1643 mutex_lock(&s->open_mutex);
1642 } 1644 }
1643 s->fmt = AFMT_U8; 1645 s->fmt = AFMT_U8;
1644 s->channels = 1; 1646 s->channels = 1;
@@ -1650,7 +1652,7 @@ static int solo1_open(struct inode *inode, struct file *file)
1650 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = s->dma_dac.subdivision = 0; 1652 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = s->dma_dac.subdivision = 0;
1651 s->dma_dac.enabled = 1; 1653 s->dma_dac.enabled = 1;
1652 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1654 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1653 up(&s->open_sem); 1655 mutex_unlock(&s->open_mutex);
1654 prog_codec(s); 1656 prog_codec(s);
1655 return nonseekable_open(inode, file); 1657 return nonseekable_open(inode, file);
1656} 1658}
@@ -1911,21 +1913,21 @@ static int solo1_midi_open(struct inode *inode, struct file *file)
1911 VALIDATE_STATE(s); 1913 VALIDATE_STATE(s);
1912 file->private_data = s; 1914 file->private_data = s;
1913 /* wait for device to become free */ 1915 /* wait for device to become free */
1914 down(&s->open_sem); 1916 mutex_lock(&s->open_mutex);
1915 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 1917 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
1916 if (file->f_flags & O_NONBLOCK) { 1918 if (file->f_flags & O_NONBLOCK) {
1917 up(&s->open_sem); 1919 mutex_unlock(&s->open_mutex);
1918 return -EBUSY; 1920 return -EBUSY;
1919 } 1921 }
1920 add_wait_queue(&s->open_wait, &wait); 1922 add_wait_queue(&s->open_wait, &wait);
1921 __set_current_state(TASK_INTERRUPTIBLE); 1923 __set_current_state(TASK_INTERRUPTIBLE);
1922 up(&s->open_sem); 1924 mutex_unlock(&s->open_mutex);
1923 schedule(); 1925 schedule();
1924 remove_wait_queue(&s->open_wait, &wait); 1926 remove_wait_queue(&s->open_wait, &wait);
1925 set_current_state(TASK_RUNNING); 1927 set_current_state(TASK_RUNNING);
1926 if (signal_pending(current)) 1928 if (signal_pending(current))
1927 return -ERESTARTSYS; 1929 return -ERESTARTSYS;
1928 down(&s->open_sem); 1930 mutex_lock(&s->open_mutex);
1929 } 1931 }
1930 spin_lock_irqsave(&s->lock, flags); 1932 spin_lock_irqsave(&s->lock, flags);
1931 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 1933 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -1951,7 +1953,7 @@ static int solo1_midi_open(struct inode *inode, struct file *file)
1951 } 1953 }
1952 spin_unlock_irqrestore(&s->lock, flags); 1954 spin_unlock_irqrestore(&s->lock, flags);
1953 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 1955 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
1954 up(&s->open_sem); 1956 mutex_unlock(&s->open_mutex);
1955 return nonseekable_open(inode, file); 1957 return nonseekable_open(inode, file);
1956} 1958}
1957 1959
@@ -1985,7 +1987,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file)
1985 remove_wait_queue(&s->midi.owait, &wait); 1987 remove_wait_queue(&s->midi.owait, &wait);
1986 set_current_state(TASK_RUNNING); 1988 set_current_state(TASK_RUNNING);
1987 } 1989 }
1988 down(&s->open_sem); 1990 mutex_lock(&s->open_mutex);
1989 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 1991 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
1990 spin_lock_irqsave(&s->lock, flags); 1992 spin_lock_irqsave(&s->lock, flags);
1991 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 1993 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -1994,7 +1996,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file)
1994 } 1996 }
1995 spin_unlock_irqrestore(&s->lock, flags); 1997 spin_unlock_irqrestore(&s->lock, flags);
1996 wake_up(&s->open_wait); 1998 wake_up(&s->open_wait);
1997 up(&s->open_sem); 1999 mutex_unlock(&s->open_mutex);
1998 unlock_kernel(); 2000 unlock_kernel();
1999 return 0; 2001 return 0;
2000} 2002}
@@ -2132,24 +2134,24 @@ static int solo1_dmfm_open(struct inode *inode, struct file *file)
2132 VALIDATE_STATE(s); 2134 VALIDATE_STATE(s);
2133 file->private_data = s; 2135 file->private_data = s;
2134 /* wait for device to become free */ 2136 /* wait for device to become free */
2135 down(&s->open_sem); 2137 mutex_lock(&s->open_mutex);
2136 while (s->open_mode & FMODE_DMFM) { 2138 while (s->open_mode & FMODE_DMFM) {
2137 if (file->f_flags & O_NONBLOCK) { 2139 if (file->f_flags & O_NONBLOCK) {
2138 up(&s->open_sem); 2140 mutex_unlock(&s->open_mutex);
2139 return -EBUSY; 2141 return -EBUSY;
2140 } 2142 }
2141 add_wait_queue(&s->open_wait, &wait); 2143 add_wait_queue(&s->open_wait, &wait);
2142 __set_current_state(TASK_INTERRUPTIBLE); 2144 __set_current_state(TASK_INTERRUPTIBLE);
2143 up(&s->open_sem); 2145 mutex_unlock(&s->open_mutex);
2144 schedule(); 2146 schedule();
2145 remove_wait_queue(&s->open_wait, &wait); 2147 remove_wait_queue(&s->open_wait, &wait);
2146 set_current_state(TASK_RUNNING); 2148 set_current_state(TASK_RUNNING);
2147 if (signal_pending(current)) 2149 if (signal_pending(current))
2148 return -ERESTARTSYS; 2150 return -ERESTARTSYS;
2149 down(&s->open_sem); 2151 mutex_lock(&s->open_mutex);
2150 } 2152 }
2151 if (!request_region(s->sbbase, FMSYNTH_EXTENT, "ESS Solo1")) { 2153 if (!request_region(s->sbbase, FMSYNTH_EXTENT, "ESS Solo1")) {
2152 up(&s->open_sem); 2154 mutex_unlock(&s->open_mutex);
2153 printk(KERN_ERR "solo1: FM synth io ports in use, opl3 loaded?\n"); 2155 printk(KERN_ERR "solo1: FM synth io ports in use, opl3 loaded?\n");
2154 return -EBUSY; 2156 return -EBUSY;
2155 } 2157 }
@@ -2161,7 +2163,7 @@ static int solo1_dmfm_open(struct inode *inode, struct file *file)
2161 outb(5, s->sbbase+2); 2163 outb(5, s->sbbase+2);
2162 outb(1, s->sbbase+3); /* enable OPL3 */ 2164 outb(1, s->sbbase+3); /* enable OPL3 */
2163 s->open_mode |= FMODE_DMFM; 2165 s->open_mode |= FMODE_DMFM;
2164 up(&s->open_sem); 2166 mutex_unlock(&s->open_mutex);
2165 return nonseekable_open(inode, file); 2167 return nonseekable_open(inode, file);
2166} 2168}
2167 2169
@@ -2172,7 +2174,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file)
2172 2174
2173 VALIDATE_STATE(s); 2175 VALIDATE_STATE(s);
2174 lock_kernel(); 2176 lock_kernel();
2175 down(&s->open_sem); 2177 mutex_lock(&s->open_mutex);
2176 s->open_mode &= ~FMODE_DMFM; 2178 s->open_mode &= ~FMODE_DMFM;
2177 for (regb = 0xb0; regb < 0xb9; regb++) { 2179 for (regb = 0xb0; regb < 0xb9; regb++) {
2178 outb(regb, s->sbbase); 2180 outb(regb, s->sbbase);
@@ -2182,7 +2184,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file)
2182 } 2184 }
2183 release_region(s->sbbase, FMSYNTH_EXTENT); 2185 release_region(s->sbbase, FMSYNTH_EXTENT);
2184 wake_up(&s->open_wait); 2186 wake_up(&s->open_wait);
2185 up(&s->open_sem); 2187 mutex_unlock(&s->open_mutex);
2186 unlock_kernel(); 2188 unlock_kernel();
2187 return 0; 2189 return 0;
2188} 2190}
@@ -2362,7 +2364,7 @@ static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device
2362 init_waitqueue_head(&s->open_wait); 2364 init_waitqueue_head(&s->open_wait);
2363 init_waitqueue_head(&s->midi.iwait); 2365 init_waitqueue_head(&s->midi.iwait);
2364 init_waitqueue_head(&s->midi.owait); 2366 init_waitqueue_head(&s->midi.owait);
2365 init_MUTEX(&s->open_sem); 2367 mutex_init(&s->open_mutex);
2366 spin_lock_init(&s->lock); 2368 spin_lock_init(&s->lock);
2367 s->magic = SOLO1_MAGIC; 2369 s->magic = SOLO1_MAGIC;
2368 s->dev = pcidev; 2370 s->dev = pcidev;
diff --git a/sound/oss/forte.c b/sound/oss/forte.c
index 8406bc90c4ff..0294eec8ad90 100644
--- a/sound/oss/forte.c
+++ b/sound/oss/forte.c
@@ -43,6 +43,7 @@
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44 44
45#include <linux/proc_fs.h> 45#include <linux/proc_fs.h>
46#include <linux/mutex.h>
46 47
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48#include <asm/io.h> 49#include <asm/io.h>
@@ -185,7 +186,7 @@ struct forte_chip {
185 unsigned long iobase; 186 unsigned long iobase;
186 int irq; 187 int irq;
187 188
188 struct semaphore open_sem; /* Device access */ 189 struct mutex open_mutex; /* Device access */
189 spinlock_t lock; /* State */ 190 spinlock_t lock; /* State */
190 191
191 spinlock_t ac97_lock; 192 spinlock_t ac97_lock;
@@ -1242,13 +1243,13 @@ forte_dsp_open (struct inode *inode, struct file *file)
1242 struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */ 1243 struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */
1243 1244
1244 if (file->f_flags & O_NONBLOCK) { 1245 if (file->f_flags & O_NONBLOCK) {
1245 if (down_trylock (&chip->open_sem)) { 1246 if (!mutex_trylock(&chip->open_mutex)) {
1246 DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__); 1247 DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__);
1247 return -EAGAIN; 1248 return -EAGAIN;
1248 } 1249 }
1249 } 1250 }
1250 else { 1251 else {
1251 if (down_interruptible (&chip->open_sem)) { 1252 if (mutex_lock_interruptible(&chip->open_mutex)) {
1252 DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__); 1253 DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__);
1253 return -ERESTARTSYS; 1254 return -ERESTARTSYS;
1254 } 1255 }
@@ -1302,7 +1303,7 @@ forte_dsp_release (struct inode *inode, struct file *file)
1302 spin_unlock_irq (&chip->lock); 1303 spin_unlock_irq (&chip->lock);
1303 } 1304 }
1304 1305
1305 up (&chip->open_sem); 1306 mutex_unlock(&chip->open_mutex);
1306 1307
1307 return ret; 1308 return ret;
1308} 1309}
@@ -2011,7 +2012,7 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
2011 memset (chip, 0, sizeof (struct forte_chip)); 2012 memset (chip, 0, sizeof (struct forte_chip));
2012 chip->pci_dev = pci_dev; 2013 chip->pci_dev = pci_dev;
2013 2014
2014 init_MUTEX(&chip->open_sem); 2015 mutex_init(&chip->open_mutex);
2015 spin_lock_init (&chip->lock); 2016 spin_lock_init (&chip->lock);
2016 spin_lock_init (&chip->ac97_lock); 2017 spin_lock_init (&chip->ac97_lock);
2017 2018
diff --git a/sound/oss/hal2.c b/sound/oss/hal2.c
index afe97c4ce069..dd4f59d30a3a 100644
--- a/sound/oss/hal2.c
+++ b/sound/oss/hal2.c
@@ -32,6 +32,8 @@
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/sound.h> 33#include <linux/sound.h>
34#include <linux/soundcard.h> 34#include <linux/soundcard.h>
35#include <linux/mutex.h>
36
35 37
36#include <asm/io.h> 38#include <asm/io.h>
37#include <asm/sgi/hpc3.h> 39#include <asm/sgi/hpc3.h>
@@ -92,7 +94,7 @@ struct hal2_codec {
92 94
93 wait_queue_head_t dma_wait; 95 wait_queue_head_t dma_wait;
94 spinlock_t lock; 96 spinlock_t lock;
95 struct semaphore sem; 97 struct mutex sem;
96 98
97 int usecount; /* recording and playback are 99 int usecount; /* recording and playback are
98 * independent */ 100 * independent */
@@ -1178,7 +1180,7 @@ static ssize_t hal2_read(struct file *file, char *buffer,
1178 1180
1179 if (!count) 1181 if (!count)
1180 return 0; 1182 return 0;
1181 if (down_interruptible(&adc->sem)) 1183 if (mutex_lock_interruptible(&adc->sem))
1182 return -EINTR; 1184 return -EINTR;
1183 if (file->f_flags & O_NONBLOCK) { 1185 if (file->f_flags & O_NONBLOCK) {
1184 err = hal2_get_buffer(hal2, buffer, count); 1186 err = hal2_get_buffer(hal2, buffer, count);
@@ -1217,7 +1219,7 @@ static ssize_t hal2_read(struct file *file, char *buffer,
1217 } 1219 }
1218 } while (count > 0 && err >= 0); 1220 } while (count > 0 && err >= 0);
1219 } 1221 }
1220 up(&adc->sem); 1222 mutex_unlock(&adc->sem);
1221 1223
1222 return err; 1224 return err;
1223} 1225}
@@ -1232,7 +1234,7 @@ static ssize_t hal2_write(struct file *file, const char *buffer,
1232 1234
1233 if (!count) 1235 if (!count)
1234 return 0; 1236 return 0;
1235 if (down_interruptible(&dac->sem)) 1237 if (mutex_lock_interruptible(&dac->sem))
1236 return -EINTR; 1238 return -EINTR;
1237 if (file->f_flags & O_NONBLOCK) { 1239 if (file->f_flags & O_NONBLOCK) {
1238 err = hal2_add_buffer(hal2, buf, count); 1240 err = hal2_add_buffer(hal2, buf, count);
@@ -1271,7 +1273,7 @@ static ssize_t hal2_write(struct file *file, const char *buffer,
1271 } 1273 }
1272 } while (count > 0 && err >= 0); 1274 } while (count > 0 && err >= 0);
1273 } 1275 }
1274 up(&dac->sem); 1276 mutex_unlock(&dac->sem);
1275 1277
1276 return err; 1278 return err;
1277} 1279}
@@ -1356,20 +1358,20 @@ static int hal2_release(struct inode *inode, struct file *file)
1356 if (file->f_mode & FMODE_READ) { 1358 if (file->f_mode & FMODE_READ) {
1357 struct hal2_codec *adc = &hal2->adc; 1359 struct hal2_codec *adc = &hal2->adc;
1358 1360
1359 down(&adc->sem); 1361 mutex_lock(&adc->sem);
1360 hal2_stop_adc(hal2); 1362 hal2_stop_adc(hal2);
1361 hal2_free_adc_dmabuf(adc); 1363 hal2_free_adc_dmabuf(adc);
1362 adc->usecount--; 1364 adc->usecount--;
1363 up(&adc->sem); 1365 mutex_unlock(&adc->sem);
1364 } 1366 }
1365 if (file->f_mode & FMODE_WRITE) { 1367 if (file->f_mode & FMODE_WRITE) {
1366 struct hal2_codec *dac = &hal2->dac; 1368 struct hal2_codec *dac = &hal2->dac;
1367 1369
1368 down(&dac->sem); 1370 mutex_lock(&dac->sem);
1369 hal2_sync_dac(hal2); 1371 hal2_sync_dac(hal2);
1370 hal2_free_dac_dmabuf(dac); 1372 hal2_free_dac_dmabuf(dac);
1371 dac->usecount--; 1373 dac->usecount--;
1372 up(&dac->sem); 1374 mutex_unlock(&dac->sem);
1373 } 1375 }
1374 1376
1375 return 0; 1377 return 0;
@@ -1400,7 +1402,7 @@ static void hal2_init_codec(struct hal2_codec *codec, struct hpc3_regs *hpc3,
1400 codec->pbus.pbusnr = index; 1402 codec->pbus.pbusnr = index;
1401 codec->pbus.pbus = &hpc3->pbdma[index]; 1403 codec->pbus.pbus = &hpc3->pbdma[index];
1402 init_waitqueue_head(&codec->dma_wait); 1404 init_waitqueue_head(&codec->dma_wait);
1403 init_MUTEX(&codec->sem); 1405 mutex_init(&codec->sem);
1404 spin_lock_init(&codec->lock); 1406 spin_lock_init(&codec->lock);
1405} 1407}
1406 1408
diff --git a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
index abc242abd5b1..dd2b871cdac5 100644
--- a/sound/oss/i810_audio.c
+++ b/sound/oss/i810_audio.c
@@ -100,6 +100,8 @@
100#include <linux/smp_lock.h> 100#include <linux/smp_lock.h>
101#include <linux/ac97_codec.h> 101#include <linux/ac97_codec.h>
102#include <linux/bitops.h> 102#include <linux/bitops.h>
103#include <linux/mutex.h>
104
103#include <asm/uaccess.h> 105#include <asm/uaccess.h>
104 106
105#define DRIVER_VERSION "1.01" 107#define DRIVER_VERSION "1.01"
@@ -331,7 +333,7 @@ struct i810_state {
331 struct i810_card *card; /* Card info */ 333 struct i810_card *card; /* Card info */
332 334
333 /* single open lock mechanism, only used for recording */ 335 /* single open lock mechanism, only used for recording */
334 struct semaphore open_sem; 336 struct mutex open_mutex;
335 wait_queue_head_t open_wait; 337 wait_queue_head_t open_wait;
336 338
337 /* file mode */ 339 /* file mode */
@@ -2597,7 +2599,7 @@ found_virt:
2597 state->card = card; 2599 state->card = card;
2598 state->magic = I810_STATE_MAGIC; 2600 state->magic = I810_STATE_MAGIC;
2599 init_waitqueue_head(&dmabuf->wait); 2601 init_waitqueue_head(&dmabuf->wait);
2600 init_MUTEX(&state->open_sem); 2602 mutex_init(&state->open_mutex);
2601 file->private_data = state; 2603 file->private_data = state;
2602 dmabuf->trigger = 0; 2604 dmabuf->trigger = 0;
2603 2605
@@ -3213,7 +3215,7 @@ static void __devinit i810_configure_clocking (void)
3213 state->card = card; 3215 state->card = card;
3214 state->magic = I810_STATE_MAGIC; 3216 state->magic = I810_STATE_MAGIC;
3215 init_waitqueue_head(&dmabuf->wait); 3217 init_waitqueue_head(&dmabuf->wait);
3216 init_MUTEX(&state->open_sem); 3218 mutex_init(&state->open_mutex);
3217 dmabuf->fmt = I810_FMT_STEREO | I810_FMT_16BIT; 3219 dmabuf->fmt = I810_FMT_STEREO | I810_FMT_16BIT;
3218 dmabuf->trigger = PCM_ENABLE_OUTPUT; 3220 dmabuf->trigger = PCM_ENABLE_OUTPUT;
3219 i810_set_spdif_output(state, -1, 0); 3221 i810_set_spdif_output(state, -1, 0);
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c
index 8fd2f9a9e668..ffcb910f5c3e 100644
--- a/sound/oss/ite8172.c
+++ b/sound/oss/ite8172.c
@@ -71,6 +71,8 @@
71#include <linux/smp_lock.h> 71#include <linux/smp_lock.h>
72#include <linux/ac97_codec.h> 72#include <linux/ac97_codec.h>
73#include <linux/interrupt.h> 73#include <linux/interrupt.h>
74#include <linux/mutex.h>
75
74#include <asm/io.h> 76#include <asm/io.h>
75#include <asm/dma.h> 77#include <asm/dma.h>
76#include <asm/uaccess.h> 78#include <asm/uaccess.h>
@@ -304,7 +306,7 @@ struct it8172_state {
304 unsigned dacrate, adcrate; 306 unsigned dacrate, adcrate;
305 307
306 spinlock_t lock; 308 spinlock_t lock;
307 struct semaphore open_sem; 309 struct mutex open_mutex;
308 mode_t open_mode; 310 mode_t open_mode;
309 wait_queue_head_t open_wait; 311 wait_queue_head_t open_wait;
310 312
@@ -1801,21 +1803,21 @@ static int it8172_open(struct inode *inode, struct file *file)
1801 } 1803 }
1802 file->private_data = s; 1804 file->private_data = s;
1803 /* wait for device to become free */ 1805 /* wait for device to become free */
1804 down(&s->open_sem); 1806 mutex_lock(&s->open_mutex);
1805 while (s->open_mode & file->f_mode) { 1807 while (s->open_mode & file->f_mode) {
1806 if (file->f_flags & O_NONBLOCK) { 1808 if (file->f_flags & O_NONBLOCK) {
1807 up(&s->open_sem); 1809 mutex_unlock(&s->open_mutex);
1808 return -EBUSY; 1810 return -EBUSY;
1809 } 1811 }
1810 add_wait_queue(&s->open_wait, &wait); 1812 add_wait_queue(&s->open_wait, &wait);
1811 __set_current_state(TASK_INTERRUPTIBLE); 1813 __set_current_state(TASK_INTERRUPTIBLE);
1812 up(&s->open_sem); 1814 mutex_unlock(&s->open_mutex);
1813 schedule(); 1815 schedule();
1814 remove_wait_queue(&s->open_wait, &wait); 1816 remove_wait_queue(&s->open_wait, &wait);
1815 set_current_state(TASK_RUNNING); 1817 set_current_state(TASK_RUNNING);
1816 if (signal_pending(current)) 1818 if (signal_pending(current))
1817 return -ERESTARTSYS; 1819 return -ERESTARTSYS;
1818 down(&s->open_sem); 1820 mutex_lock(&s->open_mutex);
1819 } 1821 }
1820 1822
1821 spin_lock_irqsave(&s->lock, flags); 1823 spin_lock_irqsave(&s->lock, flags);
@@ -1850,7 +1852,7 @@ static int it8172_open(struct inode *inode, struct file *file)
1850 spin_unlock_irqrestore(&s->lock, flags); 1852 spin_unlock_irqrestore(&s->lock, flags);
1851 1853
1852 s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); 1854 s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
1853 up(&s->open_sem); 1855 mutex_unlock(&s->open_mutex);
1854 return nonseekable_open(inode, file); 1856 return nonseekable_open(inode, file);
1855} 1857}
1856 1858
@@ -1864,7 +1866,7 @@ static int it8172_release(struct inode *inode, struct file *file)
1864 lock_kernel(); 1866 lock_kernel();
1865 if (file->f_mode & FMODE_WRITE) 1867 if (file->f_mode & FMODE_WRITE)
1866 drain_dac(s, file->f_flags & O_NONBLOCK); 1868 drain_dac(s, file->f_flags & O_NONBLOCK);
1867 down(&s->open_sem); 1869 mutex_lock(&s->open_mutex);
1868 if (file->f_mode & FMODE_WRITE) { 1870 if (file->f_mode & FMODE_WRITE) {
1869 stop_dac(s); 1871 stop_dac(s);
1870 dealloc_dmabuf(s, &s->dma_dac); 1872 dealloc_dmabuf(s, &s->dma_dac);
@@ -1874,7 +1876,7 @@ static int it8172_release(struct inode *inode, struct file *file)
1874 dealloc_dmabuf(s, &s->dma_adc); 1876 dealloc_dmabuf(s, &s->dma_adc);
1875 } 1877 }
1876 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); 1878 s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
1877 up(&s->open_sem); 1879 mutex_unlock(&s->open_mutex);
1878 wake_up(&s->open_wait); 1880 wake_up(&s->open_wait);
1879 unlock_kernel(); 1881 unlock_kernel();
1880 return 0; 1882 return 0;
@@ -1997,7 +1999,7 @@ static int __devinit it8172_probe(struct pci_dev *pcidev,
1997 init_waitqueue_head(&s->dma_adc.wait); 1999 init_waitqueue_head(&s->dma_adc.wait);
1998 init_waitqueue_head(&s->dma_dac.wait); 2000 init_waitqueue_head(&s->dma_dac.wait);
1999 init_waitqueue_head(&s->open_wait); 2001 init_waitqueue_head(&s->open_wait);
2000 init_MUTEX(&s->open_sem); 2002 mutex_init(&s->open_mutex);
2001 spin_lock_init(&s->lock); 2003 spin_lock_init(&s->lock);
2002 s->dev = pcidev; 2004 s->dev = pcidev;
2003 s->io = pci_resource_start(pcidev, 0); 2005 s->io = pci_resource_start(pcidev, 0);
diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c
index d4b569acf764..e647f2f86279 100644
--- a/sound/oss/maestro.c
+++ b/sound/oss/maestro.c
@@ -223,6 +223,8 @@
223#include <linux/reboot.h> 223#include <linux/reboot.h>
224#include <linux/bitops.h> 224#include <linux/bitops.h>
225#include <linux/wait.h> 225#include <linux/wait.h>
226#include <linux/mutex.h>
227
226 228
227#include <asm/current.h> 229#include <asm/current.h>
228#include <asm/dma.h> 230#include <asm/dma.h>
@@ -397,7 +399,7 @@ struct ess_state {
397 /* this locks around the oss state in the driver */ 399 /* this locks around the oss state in the driver */
398 spinlock_t lock; 400 spinlock_t lock;
399 /* only let 1 be opening at a time */ 401 /* only let 1 be opening at a time */
400 struct semaphore open_sem; 402 struct mutex open_mutex;
401 wait_queue_head_t open_wait; 403 wait_queue_head_t open_wait;
402 mode_t open_mode; 404 mode_t open_mode;
403 405
@@ -3020,26 +3022,26 @@ ess_open(struct inode *inode, struct file *file)
3020 VALIDATE_STATE(s); 3022 VALIDATE_STATE(s);
3021 file->private_data = s; 3023 file->private_data = s;
3022 /* wait for device to become free */ 3024 /* wait for device to become free */
3023 down(&s->open_sem); 3025 mutex_lock(&s->open_mutex);
3024 while (s->open_mode & file->f_mode) { 3026 while (s->open_mode & file->f_mode) {
3025 if (file->f_flags & O_NONBLOCK) { 3027 if (file->f_flags & O_NONBLOCK) {
3026 up(&s->open_sem); 3028 mutex_unlock(&s->open_mutex);
3027 return -EWOULDBLOCK; 3029 return -EWOULDBLOCK;
3028 } 3030 }
3029 up(&s->open_sem); 3031 mutex_unlock(&s->open_mutex);
3030 interruptible_sleep_on(&s->open_wait); 3032 interruptible_sleep_on(&s->open_wait);
3031 if (signal_pending(current)) 3033 if (signal_pending(current))
3032 return -ERESTARTSYS; 3034 return -ERESTARTSYS;
3033 down(&s->open_sem); 3035 mutex_lock(&s->open_mutex);
3034 } 3036 }
3035 3037
3036 /* under semaphore.. */ 3038 /* under semaphore.. */
3037 if ((s->card->dmapages==NULL) && allocate_buffers(s)) { 3039 if ((s->card->dmapages==NULL) && allocate_buffers(s)) {
3038 up(&s->open_sem); 3040 mutex_unlock(&s->open_mutex);
3039 return -ENOMEM; 3041 return -ENOMEM;
3040 } 3042 }
3041 3043
3042 /* we're covered by the open_sem */ 3044 /* we're covered by the open_mutex */
3043 if( ! s->card->dsps_open ) { 3045 if( ! s->card->dsps_open ) {
3044 maestro_power(s->card,ACPI_D0); 3046 maestro_power(s->card,ACPI_D0);
3045 start_bob(s); 3047 start_bob(s);
@@ -3076,7 +3078,7 @@ ess_open(struct inode *inode, struct file *file)
3076 set_fmt(s, fmtm, fmts); 3078 set_fmt(s, fmtm, fmts);
3077 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 3079 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
3078 3080
3079 up(&s->open_sem); 3081 mutex_unlock(&s->open_mutex);
3080 return nonseekable_open(inode, file); 3082 return nonseekable_open(inode, file);
3081} 3083}
3082 3084
@@ -3089,7 +3091,7 @@ ess_release(struct inode *inode, struct file *file)
3089 lock_kernel(); 3091 lock_kernel();
3090 if (file->f_mode & FMODE_WRITE) 3092 if (file->f_mode & FMODE_WRITE)
3091 drain_dac(s, file->f_flags & O_NONBLOCK); 3093 drain_dac(s, file->f_flags & O_NONBLOCK);
3092 down(&s->open_sem); 3094 mutex_lock(&s->open_mutex);
3093 if (file->f_mode & FMODE_WRITE) { 3095 if (file->f_mode & FMODE_WRITE) {
3094 stop_dac(s); 3096 stop_dac(s);
3095 } 3097 }
@@ -3098,7 +3100,7 @@ ess_release(struct inode *inode, struct file *file)
3098 } 3100 }
3099 3101
3100 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 3102 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3101 /* we're covered by the open_sem */ 3103 /* we're covered by the open_mutex */
3102 M_printk("maestro: %d dsps now alive\n",s->card->dsps_open-1); 3104 M_printk("maestro: %d dsps now alive\n",s->card->dsps_open-1);
3103 if( --s->card->dsps_open <= 0) { 3105 if( --s->card->dsps_open <= 0) {
3104 s->card->dsps_open = 0; 3106 s->card->dsps_open = 0;
@@ -3106,7 +3108,7 @@ ess_release(struct inode *inode, struct file *file)
3106 free_buffers(s); 3108 free_buffers(s);
3107 maestro_power(s->card,ACPI_D2); 3109 maestro_power(s->card,ACPI_D2);
3108 } 3110 }
3109 up(&s->open_sem); 3111 mutex_unlock(&s->open_mutex);
3110 wake_up(&s->open_wait); 3112 wake_up(&s->open_wait);
3111 unlock_kernel(); 3113 unlock_kernel();
3112 return 0; 3114 return 0;
@@ -3466,7 +3468,7 @@ maestro_probe(struct pci_dev *pcidev,const struct pci_device_id *pdid)
3466 init_waitqueue_head(&s->dma_dac.wait); 3468 init_waitqueue_head(&s->dma_dac.wait);
3467 init_waitqueue_head(&s->open_wait); 3469 init_waitqueue_head(&s->open_wait);
3468 spin_lock_init(&s->lock); 3470 spin_lock_init(&s->lock);
3469 init_MUTEX(&s->open_sem); 3471 mutex_init(&s->open_mutex);
3470 s->magic = ESS_STATE_MAGIC; 3472 s->magic = ESS_STATE_MAGIC;
3471 3473
3472 s->apu[0] = 6*i; 3474 s->apu[0] = 6*i;
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);
diff --git a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
index fbb9170e8e0a..21c1954d9108 100644
--- a/sound/oss/nec_vrc5477.c
+++ b/sound/oss/nec_vrc5477.c
@@ -78,6 +78,8 @@
78#include <linux/spinlock.h> 78#include <linux/spinlock.h>
79#include <linux/smp_lock.h> 79#include <linux/smp_lock.h>
80#include <linux/ac97_codec.h> 80#include <linux/ac97_codec.h>
81#include <linux/mutex.h>
82
81#include <asm/io.h> 83#include <asm/io.h>
82#include <asm/dma.h> 84#include <asm/dma.h>
83#include <asm/uaccess.h> 85#include <asm/uaccess.h>
@@ -198,7 +200,7 @@ struct vrc5477_ac97_state {
198 unsigned short extended_status; 200 unsigned short extended_status;
199 201
200 spinlock_t lock; 202 spinlock_t lock;
201 struct semaphore open_sem; 203 struct mutex open_mutex;
202 mode_t open_mode; 204 mode_t open_mode;
203 wait_queue_head_t open_wait; 205 wait_queue_head_t open_wait;
204 206
@@ -1617,22 +1619,22 @@ static int vrc5477_ac97_open(struct inode *inode, struct file *file)
1617 file->private_data = s; 1619 file->private_data = s;
1618 1620
1619 /* wait for device to become free */ 1621 /* wait for device to become free */
1620 down(&s->open_sem); 1622 mutex_lock(&s->open_mutex);
1621 while (s->open_mode & file->f_mode) { 1623 while (s->open_mode & file->f_mode) {
1622 1624
1623 if (file->f_flags & O_NONBLOCK) { 1625 if (file->f_flags & O_NONBLOCK) {
1624 up(&s->open_sem); 1626 mutex_unlock(&s->open_mutex);
1625 return -EBUSY; 1627 return -EBUSY;
1626 } 1628 }
1627 add_wait_queue(&s->open_wait, &wait); 1629 add_wait_queue(&s->open_wait, &wait);
1628 __set_current_state(TASK_INTERRUPTIBLE); 1630 __set_current_state(TASK_INTERRUPTIBLE);
1629 up(&s->open_sem); 1631 mutex_unlock(&s->open_mutex);
1630 schedule(); 1632 schedule();
1631 remove_wait_queue(&s->open_wait, &wait); 1633 remove_wait_queue(&s->open_wait, &wait);
1632 set_current_state(TASK_RUNNING); 1634 set_current_state(TASK_RUNNING);
1633 if (signal_pending(current)) 1635 if (signal_pending(current))
1634 return -ERESTARTSYS; 1636 return -ERESTARTSYS;
1635 down(&s->open_sem); 1637 mutex_lock(&s->open_mutex);
1636 } 1638 }
1637 1639
1638 spin_lock_irqsave(&s->lock, flags); 1640 spin_lock_irqsave(&s->lock, flags);
@@ -1659,7 +1661,7 @@ static int vrc5477_ac97_open(struct inode *inode, struct file *file)
1659 bailout: 1661 bailout:
1660 spin_unlock_irqrestore(&s->lock, flags); 1662 spin_unlock_irqrestore(&s->lock, flags);
1661 1663
1662 up(&s->open_sem); 1664 mutex_unlock(&s->open_mutex);
1663 return ret; 1665 return ret;
1664} 1666}
1665 1667
@@ -1671,7 +1673,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
1671 lock_kernel(); 1673 lock_kernel();
1672 if (file->f_mode & FMODE_WRITE) 1674 if (file->f_mode & FMODE_WRITE)
1673 drain_dac(s, file->f_flags & O_NONBLOCK); 1675 drain_dac(s, file->f_flags & O_NONBLOCK);
1674 down(&s->open_sem); 1676 mutex_lock(&s->open_mutex);
1675 if (file->f_mode & FMODE_WRITE) { 1677 if (file->f_mode & FMODE_WRITE) {
1676 stop_dac(s); 1678 stop_dac(s);
1677 dealloc_dmabuf(s, &s->dma_dac); 1679 dealloc_dmabuf(s, &s->dma_dac);
@@ -1681,7 +1683,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
1681 dealloc_dmabuf(s, &s->dma_adc); 1683 dealloc_dmabuf(s, &s->dma_adc);
1682 } 1684 }
1683 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); 1685 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
1684 up(&s->open_sem); 1686 mutex_unlock(&s->open_mutex);
1685 wake_up(&s->open_wait); 1687 wake_up(&s->open_wait);
1686 unlock_kernel(); 1688 unlock_kernel();
1687 return 0; 1689 return 0;
@@ -1867,7 +1869,7 @@ static int __devinit vrc5477_ac97_probe(struct pci_dev *pcidev,
1867 init_waitqueue_head(&s->dma_adc.wait); 1869 init_waitqueue_head(&s->dma_adc.wait);
1868 init_waitqueue_head(&s->dma_dac.wait); 1870 init_waitqueue_head(&s->dma_dac.wait);
1869 init_waitqueue_head(&s->open_wait); 1871 init_waitqueue_head(&s->open_wait);
1870 init_MUTEX(&s->open_sem); 1872 mutex_init(&s->open_mutex);
1871 spin_lock_init(&s->lock); 1873 spin_lock_init(&s->lock);
1872 1874
1873 s->dev = pcidev; 1875 s->dev = pcidev;
diff --git a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
index faa0b7919b65..a1ec9d131ab3 100644
--- a/sound/oss/rme96xx.c
+++ b/sound/oss/rme96xx.c
@@ -58,6 +58,7 @@ TODO:
58#include <linux/interrupt.h> 58#include <linux/interrupt.h>
59#include <linux/poll.h> 59#include <linux/poll.h>
60#include <linux/wait.h> 60#include <linux/wait.h>
61#include <linux/mutex.h>
61 62
62#include <asm/dma.h> 63#include <asm/dma.h>
63#include <asm/page.h> 64#include <asm/page.h>
@@ -326,7 +327,7 @@ typedef struct _rme96xx_info {
326 327
327 /* waiting and locking */ 328 /* waiting and locking */
328 wait_queue_head_t wait; 329 wait_queue_head_t wait;
329 struct semaphore open_sem; 330 struct mutex open_mutex;
330 wait_queue_head_t open_wait; 331 wait_queue_head_t open_wait;
331 332
332 } dma[RME96xx_MAX_DEVS]; 333 } dma[RME96xx_MAX_DEVS];
@@ -842,7 +843,7 @@ static void busmaster_free(void* ptr,int size) {
842 843
843static int rme96xx_dmabuf_init(rme96xx_info * s,struct dmabuf* dma,int ioffset,int ooffset) { 844static int rme96xx_dmabuf_init(rme96xx_info * s,struct dmabuf* dma,int ioffset,int ooffset) {
844 845
845 init_MUTEX(&dma->open_sem); 846 mutex_init(&dma->open_mutex);
846 init_waitqueue_head(&dma->open_wait); 847 init_waitqueue_head(&dma->open_wait);
847 init_waitqueue_head(&dma->wait); 848 init_waitqueue_head(&dma->wait);
848 dma->s = s; 849 dma->s = s;
@@ -1469,21 +1470,21 @@ static int rme96xx_open(struct inode *in, struct file *f)
1469 dma = &s->dma[devnum]; 1470 dma = &s->dma[devnum];
1470 f->private_data = dma; 1471 f->private_data = dma;
1471 /* wait for device to become free */ 1472 /* wait for device to become free */
1472 down(&dma->open_sem); 1473 mutex_lock(&dma->open_mutex);
1473 while (dma->open_mode & f->f_mode) { 1474 while (dma->open_mode & f->f_mode) {
1474 if (f->f_flags & O_NONBLOCK) { 1475 if (f->f_flags & O_NONBLOCK) {
1475 up(&dma->open_sem); 1476 mutex_unlock(&dma->open_mutex);
1476 return -EBUSY; 1477 return -EBUSY;
1477 } 1478 }
1478 add_wait_queue(&dma->open_wait, &wait); 1479 add_wait_queue(&dma->open_wait, &wait);
1479 __set_current_state(TASK_INTERRUPTIBLE); 1480 __set_current_state(TASK_INTERRUPTIBLE);
1480 up(&dma->open_sem); 1481 mutex_unlock(&dma->open_mutex);
1481 schedule(); 1482 schedule();
1482 remove_wait_queue(&dma->open_wait, &wait); 1483 remove_wait_queue(&dma->open_wait, &wait);
1483 set_current_state(TASK_RUNNING); 1484 set_current_state(TASK_RUNNING);
1484 if (signal_pending(current)) 1485 if (signal_pending(current))
1485 return -ERESTARTSYS; 1486 return -ERESTARTSYS;
1486 down(&dma->open_sem); 1487 mutex_lock(&dma->open_mutex);
1487 } 1488 }
1488 1489
1489 COMM ("hardware open") 1490 COMM ("hardware open")
@@ -1492,7 +1493,7 @@ static int rme96xx_open(struct inode *in, struct file *f)
1492 1493
1493 dma->open_mode |= (f->f_mode & (FMODE_READ | FMODE_WRITE)); 1494 dma->open_mode |= (f->f_mode & (FMODE_READ | FMODE_WRITE));
1494 dma->opened = 1; 1495 dma->opened = 1;
1495 up(&dma->open_sem); 1496 mutex_unlock(&dma->open_mutex);
1496 1497
1497 DBG(printk("device num %d open finished\n",devnum)); 1498 DBG(printk("device num %d open finished\n",devnum));
1498 return 0; 1499 return 0;
@@ -1524,7 +1525,7 @@ static int rme96xx_release(struct inode *in, struct file *file)
1524 } 1525 }
1525 1526
1526 wake_up(&dma->open_wait); 1527 wake_up(&dma->open_wait);
1527 up(&dma->open_sem); 1528 mutex_unlock(&dma->open_mutex);
1528 1529
1529 return 0; 1530 return 0;
1530} 1531}
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index 71b05e2f6977..69a4b8778b51 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -116,6 +116,8 @@
116#include <linux/spinlock.h> 116#include <linux/spinlock.h>
117#include <linux/smp_lock.h> 117#include <linux/smp_lock.h>
118#include <linux/gameport.h> 118#include <linux/gameport.h>
119#include <linux/mutex.h>
120
119 121
120#include <asm/io.h> 122#include <asm/io.h>
121#include <asm/uaccess.h> 123#include <asm/uaccess.h>
@@ -328,7 +330,7 @@ struct sv_state {
328 unsigned char fmt, enable; 330 unsigned char fmt, enable;
329 331
330 spinlock_t lock; 332 spinlock_t lock;
331 struct semaphore open_sem; 333 struct mutex open_mutex;
332 mode_t open_mode; 334 mode_t open_mode;
333 wait_queue_head_t open_wait; 335 wait_queue_head_t open_wait;
334 336
@@ -1922,21 +1924,21 @@ static int sv_open(struct inode *inode, struct file *file)
1922 VALIDATE_STATE(s); 1924 VALIDATE_STATE(s);
1923 file->private_data = s; 1925 file->private_data = s;
1924 /* wait for device to become free */ 1926 /* wait for device to become free */
1925 down(&s->open_sem); 1927 mutex_lock(&s->open_mutex);
1926 while (s->open_mode & file->f_mode) { 1928 while (s->open_mode & file->f_mode) {
1927 if (file->f_flags & O_NONBLOCK) { 1929 if (file->f_flags & O_NONBLOCK) {
1928 up(&s->open_sem); 1930 mutex_unlock(&s->open_mutex);
1929 return -EBUSY; 1931 return -EBUSY;
1930 } 1932 }
1931 add_wait_queue(&s->open_wait, &wait); 1933 add_wait_queue(&s->open_wait, &wait);
1932 __set_current_state(TASK_INTERRUPTIBLE); 1934 __set_current_state(TASK_INTERRUPTIBLE);
1933 up(&s->open_sem); 1935 mutex_unlock(&s->open_mutex);
1934 schedule(); 1936 schedule();
1935 remove_wait_queue(&s->open_wait, &wait); 1937 remove_wait_queue(&s->open_wait, &wait);
1936 set_current_state(TASK_RUNNING); 1938 set_current_state(TASK_RUNNING);
1937 if (signal_pending(current)) 1939 if (signal_pending(current))
1938 return -ERESTARTSYS; 1940 return -ERESTARTSYS;
1939 down(&s->open_sem); 1941 mutex_lock(&s->open_mutex);
1940 } 1942 }
1941 if (file->f_mode & FMODE_READ) { 1943 if (file->f_mode & FMODE_READ) {
1942 fmtm &= ~((SV_CFMT_STEREO | SV_CFMT_16BIT) << SV_CFMT_CSHIFT); 1944 fmtm &= ~((SV_CFMT_STEREO | SV_CFMT_16BIT) << SV_CFMT_CSHIFT);
@@ -1956,7 +1958,7 @@ static int sv_open(struct inode *inode, struct file *file)
1956 } 1958 }
1957 set_fmt(s, fmtm, fmts); 1959 set_fmt(s, fmtm, fmts);
1958 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 1960 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1959 up(&s->open_sem); 1961 mutex_unlock(&s->open_mutex);
1960 return nonseekable_open(inode, file); 1962 return nonseekable_open(inode, file);
1961} 1963}
1962 1964
@@ -1968,7 +1970,7 @@ static int sv_release(struct inode *inode, struct file *file)
1968 lock_kernel(); 1970 lock_kernel();
1969 if (file->f_mode & FMODE_WRITE) 1971 if (file->f_mode & FMODE_WRITE)
1970 drain_dac(s, file->f_flags & O_NONBLOCK); 1972 drain_dac(s, file->f_flags & O_NONBLOCK);
1971 down(&s->open_sem); 1973 mutex_lock(&s->open_mutex);
1972 if (file->f_mode & FMODE_WRITE) { 1974 if (file->f_mode & FMODE_WRITE) {
1973 stop_dac(s); 1975 stop_dac(s);
1974 dealloc_dmabuf(s, &s->dma_dac); 1976 dealloc_dmabuf(s, &s->dma_dac);
@@ -1979,7 +1981,7 @@ static int sv_release(struct inode *inode, struct file *file)
1979 } 1981 }
1980 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE)); 1982 s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
1981 wake_up(&s->open_wait); 1983 wake_up(&s->open_wait);
1982 up(&s->open_sem); 1984 mutex_unlock(&s->open_mutex);
1983 unlock_kernel(); 1985 unlock_kernel();
1984 return 0; 1986 return 0;
1985} 1987}
@@ -2167,21 +2169,21 @@ static int sv_midi_open(struct inode *inode, struct file *file)
2167 VALIDATE_STATE(s); 2169 VALIDATE_STATE(s);
2168 file->private_data = s; 2170 file->private_data = s;
2169 /* wait for device to become free */ 2171 /* wait for device to become free */
2170 down(&s->open_sem); 2172 mutex_lock(&s->open_mutex);
2171 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { 2173 while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
2172 if (file->f_flags & O_NONBLOCK) { 2174 if (file->f_flags & O_NONBLOCK) {
2173 up(&s->open_sem); 2175 mutex_unlock(&s->open_mutex);
2174 return -EBUSY; 2176 return -EBUSY;
2175 } 2177 }
2176 add_wait_queue(&s->open_wait, &wait); 2178 add_wait_queue(&s->open_wait, &wait);
2177 __set_current_state(TASK_INTERRUPTIBLE); 2179 __set_current_state(TASK_INTERRUPTIBLE);
2178 up(&s->open_sem); 2180 mutex_unlock(&s->open_mutex);
2179 schedule(); 2181 schedule();
2180 remove_wait_queue(&s->open_wait, &wait); 2182 remove_wait_queue(&s->open_wait, &wait);
2181 set_current_state(TASK_RUNNING); 2183 set_current_state(TASK_RUNNING);
2182 if (signal_pending(current)) 2184 if (signal_pending(current))
2183 return -ERESTARTSYS; 2185 return -ERESTARTSYS;
2184 down(&s->open_sem); 2186 mutex_lock(&s->open_mutex);
2185 } 2187 }
2186 spin_lock_irqsave(&s->lock, flags); 2188 spin_lock_irqsave(&s->lock, flags);
2187 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2189 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2210,7 +2212,7 @@ static int sv_midi_open(struct inode *inode, struct file *file)
2210 } 2212 }
2211 spin_unlock_irqrestore(&s->lock, flags); 2213 spin_unlock_irqrestore(&s->lock, flags);
2212 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); 2214 s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
2213 up(&s->open_sem); 2215 mutex_unlock(&s->open_mutex);
2214 return nonseekable_open(inode, file); 2216 return nonseekable_open(inode, file);
2215} 2217}
2216 2218
@@ -2248,7 +2250,7 @@ static int sv_midi_release(struct inode *inode, struct file *file)
2248 remove_wait_queue(&s->midi.owait, &wait); 2250 remove_wait_queue(&s->midi.owait, &wait);
2249 set_current_state(TASK_RUNNING); 2251 set_current_state(TASK_RUNNING);
2250 } 2252 }
2251 down(&s->open_sem); 2253 mutex_lock(&s->open_mutex);
2252 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE)); 2254 s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
2253 spin_lock_irqsave(&s->lock, flags); 2255 spin_lock_irqsave(&s->lock, flags);
2254 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { 2256 if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2257,7 +2259,7 @@ static int sv_midi_release(struct inode *inode, struct file *file)
2257 } 2259 }
2258 spin_unlock_irqrestore(&s->lock, flags); 2260 spin_unlock_irqrestore(&s->lock, flags);
2259 wake_up(&s->open_wait); 2261 wake_up(&s->open_wait);
2260 up(&s->open_sem); 2262 mutex_unlock(&s->open_mutex);
2261 unlock_kernel(); 2263 unlock_kernel();
2262 return 0; 2264 return 0;
2263} 2265}
@@ -2388,21 +2390,21 @@ static int sv_dmfm_open(struct inode *inode, struct file *file)
2388 VALIDATE_STATE(s); 2390 VALIDATE_STATE(s);
2389 file->private_data = s; 2391 file->private_data = s;
2390 /* wait for device to become free */ 2392 /* wait for device to become free */
2391 down(&s->open_sem); 2393 mutex_lock(&s->open_mutex);
2392 while (s->open_mode & FMODE_DMFM) { 2394 while (s->open_mode & FMODE_DMFM) {
2393 if (file->f_flags & O_NONBLOCK) { 2395 if (file->f_flags & O_NONBLOCK) {
2394 up(&s->open_sem); 2396 mutex_unlock(&s->open_mutex);
2395 return -EBUSY; 2397 return -EBUSY;
2396 } 2398 }
2397 add_wait_queue(&s->open_wait, &wait); 2399 add_wait_queue(&s->open_wait, &wait);
2398 __set_current_state(TASK_INTERRUPTIBLE); 2400 __set_current_state(TASK_INTERRUPTIBLE);
2399 up(&s->open_sem); 2401 mutex_unlock(&s->open_mutex);
2400 schedule(); 2402 schedule();
2401 remove_wait_queue(&s->open_wait, &wait); 2403 remove_wait_queue(&s->open_wait, &wait);
2402 set_current_state(TASK_RUNNING); 2404 set_current_state(TASK_RUNNING);
2403 if (signal_pending(current)) 2405 if (signal_pending(current))
2404 return -ERESTARTSYS; 2406 return -ERESTARTSYS;
2405 down(&s->open_sem); 2407 mutex_lock(&s->open_mutex);
2406 } 2408 }
2407 /* init the stuff */ 2409 /* init the stuff */
2408 outb(1, s->iosynth); 2410 outb(1, s->iosynth);
@@ -2412,7 +2414,7 @@ static int sv_dmfm_open(struct inode *inode, struct file *file)
2412 outb(5, s->iosynth+2); 2414 outb(5, s->iosynth+2);
2413 outb(1, s->iosynth+3); /* enable OPL3 */ 2415 outb(1, s->iosynth+3); /* enable OPL3 */
2414 s->open_mode |= FMODE_DMFM; 2416 s->open_mode |= FMODE_DMFM;
2415 up(&s->open_sem); 2417 mutex_unlock(&s->open_mutex);
2416 return nonseekable_open(inode, file); 2418 return nonseekable_open(inode, file);
2417} 2419}
2418 2420
@@ -2423,7 +2425,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file)
2423 2425
2424 VALIDATE_STATE(s); 2426 VALIDATE_STATE(s);
2425 lock_kernel(); 2427 lock_kernel();
2426 down(&s->open_sem); 2428 mutex_lock(&s->open_mutex);
2427 s->open_mode &= ~FMODE_DMFM; 2429 s->open_mode &= ~FMODE_DMFM;
2428 for (regb = 0xb0; regb < 0xb9; regb++) { 2430 for (regb = 0xb0; regb < 0xb9; regb++) {
2429 outb(regb, s->iosynth); 2431 outb(regb, s->iosynth);
@@ -2432,7 +2434,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file)
2432 outb(0, s->iosynth+3); 2434 outb(0, s->iosynth+3);
2433 } 2435 }
2434 wake_up(&s->open_wait); 2436 wake_up(&s->open_wait);
2435 up(&s->open_sem); 2437 mutex_unlock(&s->open_mutex);
2436 unlock_kernel(); 2438 unlock_kernel();
2437 return 0; 2439 return 0;
2438} 2440}
@@ -2582,7 +2584,7 @@ static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id
2582 init_waitqueue_head(&s->open_wait); 2584 init_waitqueue_head(&s->open_wait);
2583 init_waitqueue_head(&s->midi.iwait); 2585 init_waitqueue_head(&s->midi.iwait);
2584 init_waitqueue_head(&s->midi.owait); 2586 init_waitqueue_head(&s->midi.owait);
2585 init_MUTEX(&s->open_sem); 2587 mutex_init(&s->open_mutex);
2586 spin_lock_init(&s->lock); 2588 spin_lock_init(&s->lock);
2587 s->magic = SV_MAGIC; 2589 s->magic = SV_MAGIC;
2588 s->dev = pcidev; 2590 s->dev = pcidev;
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index df4d3771fa84..dce9016cbcfd 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -76,6 +76,7 @@
76#include <linux/init.h> 76#include <linux/init.h>
77#include <linux/poll.h> 77#include <linux/poll.h>
78#include <linux/smp_lock.h> 78#include <linux/smp_lock.h>
79#include <linux/mutex.h>
79 80
80#include <asm/byteorder.h> 81#include <asm/byteorder.h>
81#include <asm/dma.h> 82#include <asm/dma.h>
@@ -291,9 +292,9 @@ struct cs4297a_state {
291 unsigned conversion:1; // conversion from 16 to 8 bit in progress 292 unsigned conversion:1; // conversion from 16 to 8 bit in progress
292 unsigned ena; 293 unsigned ena;
293 spinlock_t lock; 294 spinlock_t lock;
294 struct semaphore open_sem; 295 struct mutex open_mutex;
295 struct semaphore open_sem_adc; 296 struct mutex open_sem_adc;
296 struct semaphore open_sem_dac; 297 struct mutex open_sem_dac;
297 mode_t open_mode; 298 mode_t open_mode;
298 wait_queue_head_t open_wait; 299 wait_queue_head_t open_wait;
299 wait_queue_head_t open_wait_adc; 300 wait_queue_head_t open_wait_adc;
@@ -2352,20 +2353,20 @@ static int cs4297a_release(struct inode *inode, struct file *file)
2352 2353
2353 if (file->f_mode & FMODE_WRITE) { 2354 if (file->f_mode & FMODE_WRITE) {
2354 drain_dac(s, file->f_flags & O_NONBLOCK); 2355 drain_dac(s, file->f_flags & O_NONBLOCK);
2355 down(&s->open_sem_dac); 2356 mutex_lock(&s->open_sem_dac);
2356 stop_dac(s); 2357 stop_dac(s);
2357 dealloc_dmabuf(s, &s->dma_dac); 2358 dealloc_dmabuf(s, &s->dma_dac);
2358 s->open_mode &= ~FMODE_WRITE; 2359 s->open_mode &= ~FMODE_WRITE;
2359 up(&s->open_sem_dac); 2360 mutex_unlock(&s->open_sem_dac);
2360 wake_up(&s->open_wait_dac); 2361 wake_up(&s->open_wait_dac);
2361 } 2362 }
2362 if (file->f_mode & FMODE_READ) { 2363 if (file->f_mode & FMODE_READ) {
2363 drain_adc(s, file->f_flags & O_NONBLOCK); 2364 drain_adc(s, file->f_flags & O_NONBLOCK);
2364 down(&s->open_sem_adc); 2365 mutex_lock(&s->open_sem_adc);
2365 stop_adc(s); 2366 stop_adc(s);
2366 dealloc_dmabuf(s, &s->dma_adc); 2367 dealloc_dmabuf(s, &s->dma_adc);
2367 s->open_mode &= ~FMODE_READ; 2368 s->open_mode &= ~FMODE_READ;
2368 up(&s->open_sem_adc); 2369 mutex_unlock(&s->open_sem_adc);
2369 wake_up(&s->open_wait_adc); 2370 wake_up(&s->open_wait_adc);
2370 } 2371 }
2371 return 0; 2372 return 0;
@@ -2413,37 +2414,37 @@ static int cs4297a_open(struct inode *inode, struct file *file)
2413 ; 2414 ;
2414 } 2415 }
2415 2416
2416 down(&s->open_sem_dac); 2417 mutex_lock(&s->open_sem_dac);
2417 while (s->open_mode & FMODE_WRITE) { 2418 while (s->open_mode & FMODE_WRITE) {
2418 if (file->f_flags & O_NONBLOCK) { 2419 if (file->f_flags & O_NONBLOCK) {
2419 up(&s->open_sem_dac); 2420 mutex_unlock(&s->open_sem_dac);
2420 return -EBUSY; 2421 return -EBUSY;
2421 } 2422 }
2422 up(&s->open_sem_dac); 2423 mutex_unlock(&s->open_sem_dac);
2423 interruptible_sleep_on(&s->open_wait_dac); 2424 interruptible_sleep_on(&s->open_wait_dac);
2424 2425
2425 if (signal_pending(current)) { 2426 if (signal_pending(current)) {
2426 printk("open - sig pending\n"); 2427 printk("open - sig pending\n");
2427 return -ERESTARTSYS; 2428 return -ERESTARTSYS;
2428 } 2429 }
2429 down(&s->open_sem_dac); 2430 mutex_lock(&s->open_sem_dac);
2430 } 2431 }
2431 } 2432 }
2432 if (file->f_mode & FMODE_READ) { 2433 if (file->f_mode & FMODE_READ) {
2433 down(&s->open_sem_adc); 2434 mutex_lock(&s->open_sem_adc);
2434 while (s->open_mode & FMODE_READ) { 2435 while (s->open_mode & FMODE_READ) {
2435 if (file->f_flags & O_NONBLOCK) { 2436 if (file->f_flags & O_NONBLOCK) {
2436 up(&s->open_sem_adc); 2437 mutex_unlock(&s->open_sem_adc);
2437 return -EBUSY; 2438 return -EBUSY;
2438 } 2439 }
2439 up(&s->open_sem_adc); 2440 mutex_unlock(&s->open_sem_adc);
2440 interruptible_sleep_on(&s->open_wait_adc); 2441 interruptible_sleep_on(&s->open_wait_adc);
2441 2442
2442 if (signal_pending(current)) { 2443 if (signal_pending(current)) {
2443 printk("open - sig pending\n"); 2444 printk("open - sig pending\n");
2444 return -ERESTARTSYS; 2445 return -ERESTARTSYS;
2445 } 2446 }
2446 down(&s->open_sem_adc); 2447 mutex_lock(&s->open_sem_adc);
2447 } 2448 }
2448 } 2449 }
2449 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2450 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
@@ -2456,7 +2457,7 @@ static int cs4297a_open(struct inode *inode, struct file *file)
2456 s->ena &= ~FMODE_READ; 2457 s->ena &= ~FMODE_READ;
2457 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = 2458 s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
2458 s->dma_adc.subdivision = 0; 2459 s->dma_adc.subdivision = 0;
2459 up(&s->open_sem_adc); 2460 mutex_unlock(&s->open_sem_adc);
2460 2461
2461 if (prog_dmabuf_adc(s)) { 2462 if (prog_dmabuf_adc(s)) {
2462 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR 2463 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -2474,7 +2475,7 @@ static int cs4297a_open(struct inode *inode, struct file *file)
2474 s->ena &= ~FMODE_WRITE; 2475 s->ena &= ~FMODE_WRITE;
2475 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = 2476 s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
2476 s->dma_dac.subdivision = 0; 2477 s->dma_dac.subdivision = 0;
2477 up(&s->open_sem_dac); 2478 mutex_unlock(&s->open_sem_dac);
2478 2479
2479 if (prog_dmabuf_dac(s)) { 2480 if (prog_dmabuf_dac(s)) {
2480 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR 2481 CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -2631,8 +2632,8 @@ static int __init cs4297a_init(void)
2631 init_waitqueue_head(&s->open_wait); 2632 init_waitqueue_head(&s->open_wait);
2632 init_waitqueue_head(&s->open_wait_adc); 2633 init_waitqueue_head(&s->open_wait_adc);
2633 init_waitqueue_head(&s->open_wait_dac); 2634 init_waitqueue_head(&s->open_wait_dac);
2634 init_MUTEX(&s->open_sem_adc); 2635 mutex_init(&s->open_sem_adc);
2635 init_MUTEX(&s->open_sem_dac); 2636 mutex_init(&s->open_sem_dac);
2636 spin_lock_init(&s->lock); 2637 spin_lock_init(&s->lock);
2637 2638
2638 s->irq = K_INT_SER_1; 2639 s->irq = K_INT_SER_1;
diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index a21c663e7e12..e61a454a8150 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -190,7 +190,7 @@
190 * 190 *
191 * Lock order (high->low) 191 * Lock order (high->low)
192 * lock - hardware lock 192 * lock - hardware lock
193 * open_sem - guard opens 193 * open_mutex - guard opens
194 * sem - guard dmabuf, write re-entry etc 194 * sem - guard dmabuf, write re-entry etc
195 */ 195 */
196 196
@@ -216,6 +216,8 @@
216#include <linux/pm.h> 216#include <linux/pm.h>
217#include <linux/gameport.h> 217#include <linux/gameport.h>
218#include <linux/kernel.h> 218#include <linux/kernel.h>
219#include <linux/mutex.h>
220
219#include <asm/uaccess.h> 221#include <asm/uaccess.h>
220#include <asm/io.h> 222#include <asm/io.h>
221#include <asm/dma.h> 223#include <asm/dma.h>
@@ -349,7 +351,7 @@ struct trident_state {
349 unsigned chans_num; 351 unsigned chans_num;
350 unsigned long fmt_flag; 352 unsigned long fmt_flag;
351 /* Guard against mmap/write/read races */ 353 /* Guard against mmap/write/read races */
352 struct semaphore sem; 354 struct mutex sem;
353 355
354}; 356};
355 357
@@ -402,7 +404,7 @@ struct trident_card {
402 struct trident_card *next; 404 struct trident_card *next;
403 405
404 /* single open lock mechanism, only used for recording */ 406 /* single open lock mechanism, only used for recording */
405 struct semaphore open_sem; 407 struct mutex open_mutex;
406 408
407 /* The trident has a certain amount of cross channel interaction 409 /* The trident has a certain amount of cross channel interaction
408 so we use a single per card lock */ 410 so we use a single per card lock */
@@ -1881,7 +1883,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1881 if (!access_ok(VERIFY_WRITE, buffer, count)) 1883 if (!access_ok(VERIFY_WRITE, buffer, count))
1882 return -EFAULT; 1884 return -EFAULT;
1883 1885
1884 down(&state->sem); 1886 mutex_lock(&state->sem);
1885 if (!dmabuf->ready && (ret = prog_dmabuf_record(state))) 1887 if (!dmabuf->ready && (ret = prog_dmabuf_record(state)))
1886 goto out; 1888 goto out;
1887 1889
@@ -1913,7 +1915,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1913 goto out; 1915 goto out;
1914 } 1916 }
1915 1917
1916 up(&state->sem); 1918 mutex_unlock(&state->sem);
1917 /* No matter how much space left in the buffer, */ 1919 /* No matter how much space left in the buffer, */
1918 /* we have to wait until CSO == ESO/2 or CSO == ESO */ 1920 /* we have to wait until CSO == ESO/2 or CSO == ESO */
1919 /* when address engine interrupts */ 1921 /* when address engine interrupts */
@@ -1940,7 +1942,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1940 ret = -ERESTARTSYS; 1942 ret = -ERESTARTSYS;
1941 goto out; 1943 goto out;
1942 } 1944 }
1943 down(&state->sem); 1945 mutex_lock(&state->sem);
1944 if (dmabuf->mapped) { 1946 if (dmabuf->mapped) {
1945 if (!ret) 1947 if (!ret)
1946 ret = -ENXIO; 1948 ret = -ENXIO;
@@ -1968,7 +1970,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1968 start_adc(state); 1970 start_adc(state);
1969 } 1971 }
1970out: 1972out:
1971 up(&state->sem); 1973 mutex_unlock(&state->sem);
1972 return ret; 1974 return ret;
1973} 1975}
1974 1976
@@ -1996,7 +1998,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
1996 * Guard against an mmap or ioctl while writing 1998 * Guard against an mmap or ioctl while writing
1997 */ 1999 */
1998 2000
1999 down(&state->sem); 2001 mutex_lock(&state->sem);
2000 2002
2001 if (dmabuf->mapped) { 2003 if (dmabuf->mapped) {
2002 ret = -ENXIO; 2004 ret = -ENXIO;
@@ -2045,7 +2047,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2045 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2); 2047 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
2046 tmo >>= sample_shift[dmabuf->fmt]; 2048 tmo >>= sample_shift[dmabuf->fmt];
2047 unlock_set_fmt(state); 2049 unlock_set_fmt(state);
2048 up(&state->sem); 2050 mutex_unlock(&state->sem);
2049 2051
2050 /* There are two situations when sleep_on_timeout */ 2052 /* There are two situations when sleep_on_timeout */
2051 /* returns, one is when the interrupt is serviced */ 2053 /* returns, one is when the interrupt is serviced */
@@ -2073,7 +2075,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2073 ret = -ERESTARTSYS; 2075 ret = -ERESTARTSYS;
2074 goto out_nolock; 2076 goto out_nolock;
2075 } 2077 }
2076 down(&state->sem); 2078 mutex_lock(&state->sem);
2077 if (dmabuf->mapped) { 2079 if (dmabuf->mapped) {
2078 if (!ret) 2080 if (!ret)
2079 ret = -ENXIO; 2081 ret = -ENXIO;
@@ -2131,7 +2133,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2131 start_dac(state); 2133 start_dac(state);
2132 } 2134 }
2133out: 2135out:
2134 up(&state->sem); 2136 mutex_unlock(&state->sem);
2135out_nolock: 2137out_nolock:
2136 return ret; 2138 return ret;
2137} 2139}
@@ -2152,24 +2154,24 @@ trident_poll(struct file *file, struct poll_table_struct *wait)
2152 * prog_dmabuf events 2154 * prog_dmabuf events
2153 */ 2155 */
2154 2156
2155 down(&state->sem); 2157 mutex_lock(&state->sem);
2156 2158
2157 if (file->f_mode & FMODE_WRITE) { 2159 if (file->f_mode & FMODE_WRITE) {
2158 if (!dmabuf->ready && prog_dmabuf_playback(state)) { 2160 if (!dmabuf->ready && prog_dmabuf_playback(state)) {
2159 up(&state->sem); 2161 mutex_unlock(&state->sem);
2160 return 0; 2162 return 0;
2161 } 2163 }
2162 poll_wait(file, &dmabuf->wait, wait); 2164 poll_wait(file, &dmabuf->wait, wait);
2163 } 2165 }
2164 if (file->f_mode & FMODE_READ) { 2166 if (file->f_mode & FMODE_READ) {
2165 if (!dmabuf->ready && prog_dmabuf_record(state)) { 2167 if (!dmabuf->ready && prog_dmabuf_record(state)) {
2166 up(&state->sem); 2168 mutex_unlock(&state->sem);
2167 return 0; 2169 return 0;
2168 } 2170 }
2169 poll_wait(file, &dmabuf->wait, wait); 2171 poll_wait(file, &dmabuf->wait, wait);
2170 } 2172 }
2171 2173
2172 up(&state->sem); 2174 mutex_unlock(&state->sem);
2173 2175
2174 spin_lock_irqsave(&state->card->lock, flags); 2176 spin_lock_irqsave(&state->card->lock, flags);
2175 trident_update_ptr(state); 2177 trident_update_ptr(state);
@@ -2207,7 +2209,7 @@ trident_mmap(struct file *file, struct vm_area_struct *vma)
2207 * a read or write against an mmap. 2209 * a read or write against an mmap.
2208 */ 2210 */
2209 2211
2210 down(&state->sem); 2212 mutex_lock(&state->sem);
2211 2213
2212 if (vma->vm_flags & VM_WRITE) { 2214 if (vma->vm_flags & VM_WRITE) {
2213 if ((ret = prog_dmabuf_playback(state)) != 0) 2215 if ((ret = prog_dmabuf_playback(state)) != 0)
@@ -2232,7 +2234,7 @@ trident_mmap(struct file *file, struct vm_area_struct *vma)
2232 dmabuf->mapped = 1; 2234 dmabuf->mapped = 1;
2233 ret = 0; 2235 ret = 0;
2234out: 2236out:
2235 up(&state->sem); 2237 mutex_unlock(&state->sem);
2236 return ret; 2238 return ret;
2237} 2239}
2238 2240
@@ -2429,15 +2431,15 @@ trident_ioctl(struct inode *inode, struct file *file,
2429 unlock_set_fmt(state); 2431 unlock_set_fmt(state);
2430 break; 2432 break;
2431 } 2433 }
2432 down(&state->card->open_sem); 2434 mutex_lock(&state->card->open_mutex);
2433 ret = ali_allocate_other_states_resources(state, 6); 2435 ret = ali_allocate_other_states_resources(state, 6);
2434 if (ret < 0) { 2436 if (ret < 0) {
2435 up(&state->card->open_sem); 2437 mutex_unlock(&state->card->open_mutex);
2436 unlock_set_fmt(state); 2438 unlock_set_fmt(state);
2437 break; 2439 break;
2438 } 2440 }
2439 state->card->multi_channel_use_count++; 2441 state->card->multi_channel_use_count++;
2440 up(&state->card->open_sem); 2442 mutex_unlock(&state->card->open_mutex);
2441 } else 2443 } else
2442 val = 2; /*yield to 2-channels */ 2444 val = 2; /*yield to 2-channels */
2443 } else 2445 } else
@@ -2727,11 +2729,11 @@ trident_open(struct inode *inode, struct file *file)
2727 2729
2728 /* find an available virtual channel (instance of /dev/dsp) */ 2730 /* find an available virtual channel (instance of /dev/dsp) */
2729 while (card != NULL) { 2731 while (card != NULL) {
2730 down(&card->open_sem); 2732 mutex_lock(&card->open_mutex);
2731 if (file->f_mode & FMODE_READ) { 2733 if (file->f_mode & FMODE_READ) {
2732 /* Skip opens on cards that are in 6 channel mode */ 2734 /* Skip opens on cards that are in 6 channel mode */
2733 if (card->multi_channel_use_count > 0) { 2735 if (card->multi_channel_use_count > 0) {
2734 up(&card->open_sem); 2736 mutex_unlock(&card->open_mutex);
2735 card = card->next; 2737 card = card->next;
2736 continue; 2738 continue;
2737 } 2739 }
@@ -2740,16 +2742,16 @@ trident_open(struct inode *inode, struct file *file)
2740 if (card->states[i] == NULL) { 2742 if (card->states[i] == NULL) {
2741 state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL); 2743 state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
2742 if (state == NULL) { 2744 if (state == NULL) {
2743 up(&card->open_sem); 2745 mutex_unlock(&card->open_mutex);
2744 return -ENOMEM; 2746 return -ENOMEM;
2745 } 2747 }
2746 memset(state, 0, sizeof(*state)); 2748 memset(state, 0, sizeof(*state));
2747 init_MUTEX(&state->sem); 2749 mutex_init(&state->sem);
2748 dmabuf = &state->dmabuf; 2750 dmabuf = &state->dmabuf;
2749 goto found_virt; 2751 goto found_virt;
2750 } 2752 }
2751 } 2753 }
2752 up(&card->open_sem); 2754 mutex_unlock(&card->open_mutex);
2753 card = card->next; 2755 card = card->next;
2754 } 2756 }
2755 /* no more virtual channel avaiable */ 2757 /* no more virtual channel avaiable */
@@ -2816,7 +2818,7 @@ trident_open(struct inode *inode, struct file *file)
2816 } 2818 }
2817 2819
2818 state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2820 state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2819 up(&card->open_sem); 2821 mutex_unlock(&card->open_mutex);
2820 2822
2821 pr_debug("trident: open virtual channel %d, hard channel %d\n", 2823 pr_debug("trident: open virtual channel %d, hard channel %d\n",
2822 state->virt, dmabuf->channel->num); 2824 state->virt, dmabuf->channel->num);
@@ -2845,7 +2847,7 @@ trident_release(struct inode *inode, struct file *file)
2845 state->virt, dmabuf->channel->num); 2847 state->virt, dmabuf->channel->num);
2846 2848
2847 /* stop DMA state machine and free DMA buffers/channels */ 2849 /* stop DMA state machine and free DMA buffers/channels */
2848 down(&card->open_sem); 2850 mutex_lock(&card->open_mutex);
2849 2851
2850 if (file->f_mode & FMODE_WRITE) { 2852 if (file->f_mode & FMODE_WRITE) {
2851 stop_dac(state); 2853 stop_dac(state);
@@ -2878,8 +2880,8 @@ trident_release(struct inode *inode, struct file *file)
2878 card->states[state->virt] = NULL; 2880 card->states[state->virt] = NULL;
2879 kfree(state); 2881 kfree(state);
2880 2882
2881 /* we're covered by the open_sem */ 2883 /* we're covered by the open_mutex */
2882 up(&card->open_sem); 2884 mutex_unlock(&card->open_mutex);
2883 2885
2884 return 0; 2886 return 0;
2885} 2887}
@@ -4405,7 +4407,7 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4405 card->banks[BANK_B].addresses = &bank_b_addrs; 4407 card->banks[BANK_B].addresses = &bank_b_addrs;
4406 card->banks[BANK_B].bitmap = 0UL; 4408 card->banks[BANK_B].bitmap = 0UL;
4407 4409
4408 init_MUTEX(&card->open_sem); 4410 mutex_init(&card->open_mutex);
4409 spin_lock_init(&card->lock); 4411 spin_lock_init(&card->lock);
4410 init_timer(&card->timer); 4412 init_timer(&card->timer);
4411 4413
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
index 83edda93f0b4..1a921ee71aba 100644
--- a/sound/oss/via82cxxx_audio.c
+++ b/sound/oss/via82cxxx_audio.c
@@ -38,7 +38,8 @@
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <asm/semaphore.h> 41#include <linux/mutex.h>
42
42#include "sound_config.h" 43#include "sound_config.h"
43#include "dev_table.h" 44#include "dev_table.h"
44#include "mpu401.h" 45#include "mpu401.h"
@@ -311,8 +312,8 @@ struct via_info {
311 312
312 int mixer_vol; /* 8233/35 volume - not yet implemented */ 313 int mixer_vol; /* 8233/35 volume - not yet implemented */
313 314
314 struct semaphore syscall_sem; 315 struct mutex syscall_mutex;
315 struct semaphore open_sem; 316 struct mutex open_mutex;
316 317
317 /* The 8233/8235 have 4 DX audio channels, two record and 318 /* The 8233/8235 have 4 DX audio channels, two record and
318 one six channel out. We bind ch_in to DX 1, ch_out to multichannel 319 one six channel out. We bind ch_in to DX 1, ch_out to multichannel
@@ -505,10 +506,10 @@ static inline int via_syscall_down (struct via_info *card, int nonblock)
505 nonblock = 0; 506 nonblock = 0;
506 507
507 if (nonblock) { 508 if (nonblock) {
508 if (down_trylock (&card->syscall_sem)) 509 if (!mutex_trylock(&card->syscall_mutex))
509 return -EAGAIN; 510 return -EAGAIN;
510 } else { 511 } else {
511 if (down_interruptible (&card->syscall_sem)) 512 if (mutex_lock_interruptible(&card->syscall_mutex))
512 return -ERESTARTSYS; 513 return -ERESTARTSYS;
513 } 514 }
514 515
@@ -1609,7 +1610,7 @@ static int via_mixer_ioctl (struct inode *inode, struct file *file, unsigned int
1609#endif 1610#endif
1610 rc = codec->mixer_ioctl(codec, cmd, arg); 1611 rc = codec->mixer_ioctl(codec, cmd, arg);
1611 1612
1612 up (&card->syscall_sem); 1613 mutex_unlock(&card->syscall_mutex);
1613 1614
1614out: 1615out:
1615 DPRINTK ("EXIT, returning %d\n", rc); 1616 DPRINTK ("EXIT, returning %d\n", rc);
@@ -2228,7 +2229,7 @@ static int via_dsp_mmap(struct file *file, struct vm_area_struct *vma)
2228 if (wr) 2229 if (wr)
2229 card->ch_out.is_mapped = 1; 2230 card->ch_out.is_mapped = 1;
2230 2231
2231 up (&card->syscall_sem); 2232 mutex_unlock(&card->syscall_mutex);
2232 rc = 0; 2233 rc = 0;
2233 2234
2234out: 2235out:
@@ -2256,7 +2257,7 @@ handle_one_block:
2256 /* Thomas Sailer: 2257 /* Thomas Sailer:
2257 * But also to ourselves, release semaphore if we do so */ 2258 * But also to ourselves, release semaphore if we do so */
2258 if (need_resched()) { 2259 if (need_resched()) {
2259 up(&card->syscall_sem); 2260 mutex_unlock(&card->syscall_mutex);
2260 schedule (); 2261 schedule ();
2261 ret = via_syscall_down (card, nonblock); 2262 ret = via_syscall_down (card, nonblock);
2262 if (ret) 2263 if (ret)
@@ -2286,7 +2287,7 @@ handle_one_block:
2286 break; 2287 break;
2287 } 2288 }
2288 2289
2289 up(&card->syscall_sem); 2290 mutex_unlock(&card->syscall_mutex);
2290 2291
2291 DPRINTK ("Sleeping on block %d\n", n); 2292 DPRINTK ("Sleeping on block %d\n", n);
2292 schedule(); 2293 schedule();
@@ -2402,7 +2403,7 @@ static ssize_t via_dsp_read(struct file *file, char __user *buffer, size_t count
2402 rc = via_dsp_do_read (card, buffer, count, nonblock); 2403 rc = via_dsp_do_read (card, buffer, count, nonblock);
2403 2404
2404out_up: 2405out_up:
2405 up (&card->syscall_sem); 2406 mutex_unlock(&card->syscall_mutex);
2406out: 2407out:
2407 DPRINTK ("EXIT, returning %ld\n",(long) rc); 2408 DPRINTK ("EXIT, returning %ld\n",(long) rc);
2408 return rc; 2409 return rc;
@@ -2426,7 +2427,7 @@ handle_one_block:
2426 /* Thomas Sailer: 2427 /* Thomas Sailer:
2427 * But also to ourselves, release semaphore if we do so */ 2428 * But also to ourselves, release semaphore if we do so */
2428 if (need_resched()) { 2429 if (need_resched()) {
2429 up(&card->syscall_sem); 2430 mutex_unlock(&card->syscall_mutex);
2430 schedule (); 2431 schedule ();
2431 ret = via_syscall_down (card, nonblock); 2432 ret = via_syscall_down (card, nonblock);
2432 if (ret) 2433 if (ret)
@@ -2456,7 +2457,7 @@ handle_one_block:
2456 break; 2457 break;
2457 } 2458 }
2458 2459
2459 up(&card->syscall_sem); 2460 mutex_unlock(&card->syscall_mutex);
2460 2461
2461 DPRINTK ("Sleeping on page %d, tmp==%d, ir==%d\n", n, tmp, chan->is_record); 2462 DPRINTK ("Sleeping on page %d, tmp==%d, ir==%d\n", n, tmp, chan->is_record);
2462 schedule(); 2463 schedule();
@@ -2585,7 +2586,7 @@ static ssize_t via_dsp_write(struct file *file, const char __user *buffer, size_
2585 rc = via_dsp_do_write (card, buffer, count, nonblock); 2586 rc = via_dsp_do_write (card, buffer, count, nonblock);
2586 2587
2587out_up: 2588out_up:
2588 up (&card->syscall_sem); 2589 mutex_unlock(&card->syscall_mutex);
2589out: 2590out:
2590 DPRINTK ("EXIT, returning %ld\n",(long) rc); 2591 DPRINTK ("EXIT, returning %ld\n",(long) rc);
2591 return rc; 2592 return rc;
@@ -2634,7 +2635,7 @@ static unsigned int via_dsp_poll(struct file *file, struct poll_table_struct *wa
2634 * Sleeps until all playback has been flushed to the audio 2635 * Sleeps until all playback has been flushed to the audio
2635 * hardware. 2636 * hardware.
2636 * 2637 *
2637 * Locking: inside card->syscall_sem 2638 * Locking: inside card->syscall_mutex
2638 */ 2639 */
2639 2640
2640static int via_dsp_drain_playback (struct via_info *card, 2641static int via_dsp_drain_playback (struct via_info *card,
@@ -2692,7 +2693,7 @@ static int via_dsp_drain_playback (struct via_info *card,
2692 printk (KERN_ERR "sleeping but not active\n"); 2693 printk (KERN_ERR "sleeping but not active\n");
2693#endif 2694#endif
2694 2695
2695 up(&card->syscall_sem); 2696 mutex_unlock(&card->syscall_mutex);
2696 2697
2697 DPRINTK ("sleeping, nbufs=%d\n", atomic_read (&chan->n_frags)); 2698 DPRINTK ("sleeping, nbufs=%d\n", atomic_read (&chan->n_frags));
2698 schedule(); 2699 schedule();
@@ -2748,7 +2749,7 @@ out:
2748 * 2749 *
2749 * Handles SNDCTL_DSP_GETISPACE and SNDCTL_DSP_GETOSPACE. 2750 * Handles SNDCTL_DSP_GETISPACE and SNDCTL_DSP_GETOSPACE.
2750 * 2751 *
2751 * Locking: inside card->syscall_sem 2752 * Locking: inside card->syscall_mutex
2752 */ 2753 */
2753 2754
2754static int via_dsp_ioctl_space (struct via_info *card, 2755static int via_dsp_ioctl_space (struct via_info *card,
@@ -2793,7 +2794,7 @@ static int via_dsp_ioctl_space (struct via_info *card,
2793 * 2794 *
2794 * Handles SNDCTL_DSP_GETIPTR and SNDCTL_DSP_GETOPTR. 2795 * Handles SNDCTL_DSP_GETIPTR and SNDCTL_DSP_GETOPTR.
2795 * 2796 *
2796 * Locking: inside card->syscall_sem 2797 * Locking: inside card->syscall_mutex
2797 */ 2798 */
2798 2799
2799static int via_dsp_ioctl_ptr (struct via_info *card, 2800static int via_dsp_ioctl_ptr (struct via_info *card,
@@ -3221,7 +3222,7 @@ static int via_dsp_ioctl (struct inode *inode, struct file *file,
3221 break; 3222 break;
3222 } 3223 }
3223 3224
3224 up (&card->syscall_sem); 3225 mutex_unlock(&card->syscall_mutex);
3225 DPRINTK ("EXIT, returning %d\n", rc); 3226 DPRINTK ("EXIT, returning %d\n", rc);
3226 return rc; 3227 return rc;
3227} 3228}
@@ -3264,12 +3265,12 @@ static int via_dsp_open (struct inode *inode, struct file *file)
3264 3265
3265match: 3266match:
3266 if (nonblock) { 3267 if (nonblock) {
3267 if (down_trylock (&card->open_sem)) { 3268 if (!mutex_trylock(&card->open_mutex)) {
3268 DPRINTK ("EXIT, returning -EAGAIN\n"); 3269 DPRINTK ("EXIT, returning -EAGAIN\n");
3269 return -EAGAIN; 3270 return -EAGAIN;
3270 } 3271 }
3271 } else { 3272 } else {
3272 if (down_interruptible (&card->open_sem)) { 3273 if (mutex_lock_interruptible(&card->open_mutex)) {
3273 DPRINTK ("EXIT, returning -ERESTARTSYS\n"); 3274 DPRINTK ("EXIT, returning -ERESTARTSYS\n");
3274 return -ERESTARTSYS; 3275 return -ERESTARTSYS;
3275 } 3276 }
@@ -3355,8 +3356,8 @@ static int via_dsp_release(struct inode *inode, struct file *file)
3355 via_chan_buffer_free (card, &card->ch_in); 3356 via_chan_buffer_free (card, &card->ch_in);
3356 } 3357 }
3357 3358
3358 up (&card->syscall_sem); 3359 mutex_unlock(&card->syscall_mutex);
3359 up (&card->open_sem); 3360 mutex_unlock(&card->open_mutex);
3360 3361
3361 DPRINTK ("EXIT, returning 0\n"); 3362 DPRINTK ("EXIT, returning 0\n");
3362 return 0; 3363 return 0;
@@ -3414,8 +3415,8 @@ static int __devinit via_init_one (struct pci_dev *pdev, const struct pci_device
3414 card->card_num = via_num_cards++; 3415 card->card_num = via_num_cards++;
3415 spin_lock_init (&card->lock); 3416 spin_lock_init (&card->lock);
3416 spin_lock_init (&card->ac97_lock); 3417 spin_lock_init (&card->ac97_lock);
3417 init_MUTEX (&card->syscall_sem); 3418 mutex_init(&card->syscall_mutex);
3418 init_MUTEX (&card->open_sem); 3419 mutex_init(&card->open_mutex);
3419 3420
3420 /* we must init these now, in case the intr handler needs them */ 3421 /* we must init these now, in case the intr handler needs them */
3421 via_chan_init_defaults (card, &card->ch_out); 3422 via_chan_init_defaults (card, &card->ch_out);
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 265423054caf..b372e88e857f 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -94,7 +94,7 @@
94 * Open will block until the previous client has closed the 94 * Open will block until the previous client has closed the
95 * device, unless O_NONBLOCK is specified. 95 * device, unless O_NONBLOCK is specified.
96 * 96 *
97 * The semaphore devc->io_sema serializes PCM I/O syscalls. This 97 * The semaphore devc->io_mutex serializes PCM I/O syscalls. This
98 * is unnecessary in Linux 2.2, because the kernel lock 98 * is unnecessary in Linux 2.2, because the kernel lock
99 * serializes read, write, and ioctl globally, but it's there, 99 * serializes read, write, and ioctl globally, but it's there,
100 * ready for the brave, new post-kernel-lock world. 100 * ready for the brave, new post-kernel-lock world.
@@ -105,7 +105,7 @@
105 * area it owns and update its pointers. See pcm_output() and 105 * area it owns and update its pointers. See pcm_output() and
106 * pcm_input() for most of the gory stuff. 106 * pcm_input() for most of the gory stuff.
107 * 107 *
108 * devc->mix_sema serializes all mixer ioctls. This is also 108 * devc->mix_mutex serializes all mixer ioctls. This is also
109 * redundant because of the kernel lock. 109 * redundant because of the kernel lock.
110 * 110 *
111 * The lowest level lock is lith->lithium_lock. It is a 111 * The lowest level lock is lith->lithium_lock. It is a
@@ -148,7 +148,8 @@
148#include <linux/smp_lock.h> 148#include <linux/smp_lock.h>
149#include <linux/wait.h> 149#include <linux/wait.h>
150#include <linux/interrupt.h> 150#include <linux/interrupt.h>
151#include <asm/semaphore.h> 151#include <linux/mutex.h>
152
152#include <asm/mach-visws/cobalt.h> 153#include <asm/mach-visws/cobalt.h>
153 154
154#include "sound_config.h" 155#include "sound_config.h"
@@ -1447,11 +1448,11 @@ typedef enum vwsnd_port_flags {
1447 * 1448 *
1448 * port->lock protects: hwstate, flags, swb_[iu]_avail. 1449 * port->lock protects: hwstate, flags, swb_[iu]_avail.
1449 * 1450 *
1450 * devc->io_sema protects: swstate, sw_*, swb_[iu]_idx. 1451 * devc->io_mutex protects: swstate, sw_*, swb_[iu]_idx.
1451 * 1452 *
1452 * everything else is only written by open/release or 1453 * everything else is only written by open/release or
1453 * pcm_{setup,shutdown}(), which are serialized by a 1454 * pcm_{setup,shutdown}(), which are serialized by a
1454 * combination of devc->open_sema and devc->io_sema. 1455 * combination of devc->open_mutex and devc->io_mutex.
1455 */ 1456 */
1456 1457
1457typedef struct vwsnd_port { 1458typedef struct vwsnd_port {
@@ -1507,9 +1508,9 @@ typedef struct vwsnd_dev {
1507 int audio_minor; /* minor number of audio device */ 1508 int audio_minor; /* minor number of audio device */
1508 int mixer_minor; /* minor number of mixer device */ 1509 int mixer_minor; /* minor number of mixer device */
1509 1510
1510 struct semaphore open_sema; 1511 struct mutex open_mutex;
1511 struct semaphore io_sema; 1512 struct mutex io_mutex;
1512 struct semaphore mix_sema; 1513 struct mutex mix_mutex;
1513 mode_t open_mode; 1514 mode_t open_mode;
1514 wait_queue_head_t open_wait; 1515 wait_queue_head_t open_wait;
1515 1516
@@ -1633,7 +1634,7 @@ static __inline__ unsigned int swb_inc_i(vwsnd_port_t *port, int inc)
1633 * mode-setting ioctls have been done, but before the first I/O is 1634 * mode-setting ioctls have been done, but before the first I/O is
1634 * done. 1635 * done.
1635 * 1636 *
1636 * Locking: called with devc->io_sema held. 1637 * Locking: called with devc->io_mutex held.
1637 * 1638 *
1638 * Returns 0 on success, -errno on failure. 1639 * Returns 0 on success, -errno on failure.
1639 */ 1640 */
@@ -2319,9 +2320,9 @@ static ssize_t vwsnd_audio_read(struct file *file,
2319 vwsnd_dev_t *devc = file->private_data; 2320 vwsnd_dev_t *devc = file->private_data;
2320 ssize_t ret; 2321 ssize_t ret;
2321 2322
2322 down(&devc->io_sema); 2323 mutex_lock(&devc->io_mutex);
2323 ret = vwsnd_audio_do_read(file, buffer, count, ppos); 2324 ret = vwsnd_audio_do_read(file, buffer, count, ppos);
2324 up(&devc->io_sema); 2325 mutex_unlock(&devc->io_mutex);
2325 return ret; 2326 return ret;
2326} 2327}
2327 2328
@@ -2394,9 +2395,9 @@ static ssize_t vwsnd_audio_write(struct file *file,
2394 vwsnd_dev_t *devc = file->private_data; 2395 vwsnd_dev_t *devc = file->private_data;
2395 ssize_t ret; 2396 ssize_t ret;
2396 2397
2397 down(&devc->io_sema); 2398 mutex_lock(&devc->io_mutex);
2398 ret = vwsnd_audio_do_write(file, buffer, count, ppos); 2399 ret = vwsnd_audio_do_write(file, buffer, count, ppos);
2399 up(&devc->io_sema); 2400 mutex_unlock(&devc->io_mutex);
2400 return ret; 2401 return ret;
2401} 2402}
2402 2403
@@ -2891,9 +2892,9 @@ static int vwsnd_audio_ioctl(struct inode *inode,
2891 vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; 2892 vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data;
2892 int ret; 2893 int ret;
2893 2894
2894 down(&devc->io_sema); 2895 mutex_lock(&devc->io_mutex);
2895 ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg); 2896 ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg);
2896 up(&devc->io_sema); 2897 mutex_unlock(&devc->io_mutex);
2897 return ret; 2898 return ret;
2898} 2899}
2899 2900
@@ -2929,9 +2930,9 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2929 return -ENODEV; 2930 return -ENODEV;
2930 } 2931 }
2931 2932
2932 down(&devc->open_sema); 2933 mutex_lock(&devc->open_mutex);
2933 while (devc->open_mode & file->f_mode) { 2934 while (devc->open_mode & file->f_mode) {
2934 up(&devc->open_sema); 2935 mutex_unlock(&devc->open_mutex);
2935 if (file->f_flags & O_NONBLOCK) { 2936 if (file->f_flags & O_NONBLOCK) {
2936 DEC_USE_COUNT; 2937 DEC_USE_COUNT;
2937 return -EBUSY; 2938 return -EBUSY;
@@ -2941,10 +2942,10 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2941 DEC_USE_COUNT; 2942 DEC_USE_COUNT;
2942 return -ERESTARTSYS; 2943 return -ERESTARTSYS;
2943 } 2944 }
2944 down(&devc->open_sema); 2945 mutex_lock(&devc->open_mutex);
2945 } 2946 }
2946 devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); 2947 devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
2947 up(&devc->open_sema); 2948 mutex_unlock(&devc->open_mutex);
2948 2949
2949 /* get default sample format from minor number. */ 2950 /* get default sample format from minor number. */
2950 2951
@@ -2960,7 +2961,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2960 2961
2961 /* Initialize vwsnd_ports. */ 2962 /* Initialize vwsnd_ports. */
2962 2963
2963 down(&devc->io_sema); 2964 mutex_lock(&devc->io_mutex);
2964 { 2965 {
2965 if (file->f_mode & FMODE_READ) { 2966 if (file->f_mode & FMODE_READ) {
2966 devc->rport.swstate = SW_INITIAL; 2967 devc->rport.swstate = SW_INITIAL;
@@ -2987,7 +2988,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
2987 devc->wport.frag_count = 0; 2988 devc->wport.frag_count = 0;
2988 } 2989 }
2989 } 2990 }
2990 up(&devc->io_sema); 2991 mutex_unlock(&devc->io_mutex);
2991 2992
2992 file->private_data = devc; 2993 file->private_data = devc;
2993 DBGRV(); 2994 DBGRV();
@@ -3005,7 +3006,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file)
3005 int err = 0; 3006 int err = 0;
3006 3007
3007 lock_kernel(); 3008 lock_kernel();
3008 down(&devc->io_sema); 3009 mutex_lock(&devc->io_mutex);
3009 { 3010 {
3010 DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); 3011 DBGEV("(inode=0x%p, file=0x%p)\n", inode, file);
3011 3012
@@ -3022,13 +3023,13 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file)
3022 if (wport) 3023 if (wport)
3023 wport->swstate = SW_OFF; 3024 wport->swstate = SW_OFF;
3024 } 3025 }
3025 up(&devc->io_sema); 3026 mutex_unlock(&devc->io_mutex);
3026 3027
3027 down(&devc->open_sema); 3028 mutex_lock(&devc->open_mutex);
3028 { 3029 {
3029 devc->open_mode &= ~file->f_mode; 3030 devc->open_mode &= ~file->f_mode;
3030 } 3031 }
3031 up(&devc->open_sema); 3032 mutex_unlock(&devc->open_mutex);
3032 wake_up(&devc->open_wait); 3033 wake_up(&devc->open_wait);
3033 DEC_USE_COUNT; 3034 DEC_USE_COUNT;
3034 DBGR(); 3035 DBGR();
@@ -3213,7 +3214,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
3213 3214
3214 DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); 3215 DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg);
3215 3216
3216 down(&devc->mix_sema); 3217 mutex_lock(&devc->mix_mutex);
3217 { 3218 {
3218 if ((cmd & ~nrmask) == MIXER_READ(0)) 3219 if ((cmd & ~nrmask) == MIXER_READ(0))
3219 retval = mixer_read_ioctl(devc, nr, (void __user *) arg); 3220 retval = mixer_read_ioctl(devc, nr, (void __user *) arg);
@@ -3222,7 +3223,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
3222 else 3223 else
3223 retval = -EINVAL; 3224 retval = -EINVAL;
3224 } 3225 }
3225 up(&devc->mix_sema); 3226 mutex_unlock(&devc->mix_mutex);
3226 return retval; 3227 return retval;
3227} 3228}
3228 3229
@@ -3376,9 +3377,9 @@ static int __init attach_vwsnd(struct address_info *hw_config)
3376 3377
3377 /* Initialize as much of *devc as possible */ 3378 /* Initialize as much of *devc as possible */
3378 3379
3379 init_MUTEX(&devc->open_sema); 3380 mutex_init(&devc->open_mutex);
3380 init_MUTEX(&devc->io_sema); 3381 mutex_init(&devc->io_mutex);
3381 init_MUTEX(&devc->mix_sema); 3382 mutex_init(&devc->mix_mutex);
3382 devc->open_mode = 0; 3383 devc->open_mode = 0;
3383 spin_lock_init(&devc->rport.lock); 3384 spin_lock_init(&devc->rport.lock);
3384 init_waitqueue_head(&devc->rport.queue); 3385 init_waitqueue_head(&devc->rport.queue);
diff --git a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
index f8bd72e46f57..bf90c124a7e6 100644
--- a/sound/oss/ymfpci.c
+++ b/sound/oss/ymfpci.c
@@ -1918,10 +1918,10 @@ static int ymf_open(struct inode *inode, struct file *file)
1918 if (unit == NULL) 1918 if (unit == NULL)
1919 return -ENODEV; 1919 return -ENODEV;
1920 1920
1921 down(&unit->open_sem); 1921 mutex_lock(&unit->open_mutex);
1922 1922
1923 if ((state = ymf_state_alloc(unit)) == NULL) { 1923 if ((state = ymf_state_alloc(unit)) == NULL) {
1924 up(&unit->open_sem); 1924 mutex_unlock(&unit->open_mutex);
1925 return -ENOMEM; 1925 return -ENOMEM;
1926 } 1926 }
1927 list_add_tail(&state->chain, &unit->states); 1927 list_add_tail(&state->chain, &unit->states);
@@ -1956,7 +1956,7 @@ static int ymf_open(struct inode *inode, struct file *file)
1956 ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 1956 ymfpci_writeb(unit, YDSXGR_TIMERCTRL,
1957 (YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN)); 1957 (YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN));
1958#endif 1958#endif
1959 up(&unit->open_sem); 1959 mutex_unlock(&unit->open_mutex);
1960 1960
1961 return nonseekable_open(inode, file); 1961 return nonseekable_open(inode, file);
1962 1962
@@ -1974,7 +1974,7 @@ out_nodma:
1974 list_del(&state->chain); 1974 list_del(&state->chain);
1975 kfree(state); 1975 kfree(state);
1976 1976
1977 up(&unit->open_sem); 1977 mutex_unlock(&unit->open_mutex);
1978 return err; 1978 return err;
1979} 1979}
1980 1980
@@ -1987,7 +1987,7 @@ static int ymf_release(struct inode *inode, struct file *file)
1987 ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0); 1987 ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0);
1988#endif 1988#endif
1989 1989
1990 down(&unit->open_sem); 1990 mutex_lock(&unit->open_mutex);
1991 1991
1992 /* 1992 /*
1993 * XXX Solve the case of O_NONBLOCK close - don't deallocate here. 1993 * XXX Solve the case of O_NONBLOCK close - don't deallocate here.
@@ -2004,7 +2004,7 @@ static int ymf_release(struct inode *inode, struct file *file)
2004 file->private_data = NULL; /* Can you tell I programmed Solaris */ 2004 file->private_data = NULL; /* Can you tell I programmed Solaris */
2005 kfree(state); 2005 kfree(state);
2006 2006
2007 up(&unit->open_sem); 2007 mutex_unlock(&unit->open_mutex);
2008 2008
2009 return 0; 2009 return 0;
2010} 2010}
@@ -2532,7 +2532,7 @@ static int __devinit ymf_probe_one(struct pci_dev *pcidev, const struct pci_devi
2532 spin_lock_init(&codec->reg_lock); 2532 spin_lock_init(&codec->reg_lock);
2533 spin_lock_init(&codec->voice_lock); 2533 spin_lock_init(&codec->voice_lock);
2534 spin_lock_init(&codec->ac97_lock); 2534 spin_lock_init(&codec->ac97_lock);
2535 init_MUTEX(&codec->open_sem); 2535 mutex_init(&codec->open_mutex);
2536 INIT_LIST_HEAD(&codec->states); 2536 INIT_LIST_HEAD(&codec->states);
2537 codec->pci = pcidev; 2537 codec->pci = pcidev;
2538 2538
diff --git a/sound/oss/ymfpci.h b/sound/oss/ymfpci.h
index f810a100c641..ac1785f2b7e7 100644
--- a/sound/oss/ymfpci.h
+++ b/sound/oss/ymfpci.h
@@ -22,6 +22,7 @@
22 * 22 *
23 */ 23 */
24#include <linux/config.h> 24#include <linux/config.h>
25#include <linux/mutex.h>
25 26
26/* 27/*
27 * Direct registers 28 * Direct registers
@@ -279,7 +280,7 @@ struct ymf_unit {
279 280
280 /* soundcore stuff */ 281 /* soundcore stuff */
281 int dev_audio; 282 int dev_audio;
282 struct semaphore open_sem; 283 struct mutex open_mutex;
283 284
284 struct list_head ymf_devs; 285 struct list_head ymf_devs;
285 struct list_head states; /* List of states for this unit */ 286 struct list_head states; /* List of states for this unit */