aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-01-16 10:29:08 -0500
committerJaroslav Kysela <perex@suse.cz>2006-03-22 04:24:50 -0500
commit1a60d4c5a0c4028559585a74e48593b16e1ca9b2 (patch)
treef03f8dfcd554f8ebbb295522dc46dfe4d110a484
parentf0283f45a04d5cf31512e5e390a38504d97e7a97 (diff)
[ALSA] semaphore -> mutex (core part)
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: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/core.h8
-rw-r--r--include/sound/hwdep.h2
-rw-r--r--include/sound/info.h2
-rw-r--r--include/sound/mixer_oss.h2
-rw-r--r--include/sound/pcm.h2
-rw-r--r--include/sound/pcm_oss.h2
-rw-r--r--include/sound/rawmidi.h4
-rw-r--r--include/sound/seq_instr.h2
-rw-r--r--sound/core/hwdep.c43
-rw-r--r--sound/core/info.c27
-rw-r--r--sound/core/info_oss.c13
-rw-r--r--sound/core/init.c2
-rw-r--r--sound/core/memalloc.c22
-rw-r--r--sound/core/oss/mixer_oss.c14
-rw-r--r--sound/core/oss/pcm_oss.c30
-rw-r--r--sound/core/pcm.c40
-rw-r--r--sound/core/pcm_native.c12
-rw-r--r--sound/core/rawmidi.c57
-rw-r--r--sound/core/seq/oss/seq_oss.c27
-rw-r--r--sound/core/seq/seq_clientmgr.c40
-rw-r--r--sound/core/seq/seq_clientmgr.h2
-rw-r--r--sound/core/seq/seq_device.c53
-rw-r--r--sound/core/seq/seq_instr.c6
-rw-r--r--sound/core/seq/seq_midi.c20
-rw-r--r--sound/core/seq/seq_ports.c12
-rw-r--r--sound/core/seq/seq_queue.c6
-rw-r--r--sound/core/seq/seq_queue.h2
-rw-r--r--sound/core/sound.c23
-rw-r--r--sound/core/sound_oss.c23
-rw-r--r--sound/core/timer.c77
30 files changed, 293 insertions, 282 deletions
diff --git a/include/sound/core.h b/include/sound/core.h
index 3093e3ddcf36..144bdc2f217f 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include <linux/sched.h> /* wake_up() */ 25#include <linux/sched.h> /* wake_up() */
26#include <asm/semaphore.h> /* struct semaphore */ 26#include <linux/mutex.h> /* struct mutex */
27#include <linux/rwsem.h> /* struct rw_semaphore */ 27#include <linux/rwsem.h> /* struct rw_semaphore */
28#include <linux/workqueue.h> /* struct workqueue_struct */ 28#include <linux/workqueue.h> /* struct workqueue_struct */
29#include <linux/pm.h> /* pm_message_t */ 29#include <linux/pm.h> /* pm_message_t */
@@ -137,7 +137,7 @@ struct snd_card {
137 137
138#ifdef CONFIG_PM 138#ifdef CONFIG_PM
139 unsigned int power_state; /* power state */ 139 unsigned int power_state; /* power state */
140 struct semaphore power_lock; /* power lock */ 140 struct mutex power_lock; /* power lock */
141 wait_queue_head_t power_sleep; 141 wait_queue_head_t power_sleep;
142#endif 142#endif
143 143
@@ -150,12 +150,12 @@ struct snd_card {
150#ifdef CONFIG_PM 150#ifdef CONFIG_PM
151static inline void snd_power_lock(struct snd_card *card) 151static inline void snd_power_lock(struct snd_card *card)
152{ 152{
153 down(&card->power_lock); 153 mutex_lock(&card->power_lock);
154} 154}
155 155
156static inline void snd_power_unlock(struct snd_card *card) 156static inline void snd_power_unlock(struct snd_card *card)
157{ 157{
158 up(&card->power_lock); 158 mutex_unlock(&card->power_lock);
159} 159}
160 160
161static inline unsigned int snd_power_get_state(struct snd_card *card) 161static inline unsigned int snd_power_get_state(struct snd_card *card)
diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h
index c679e5b31111..94c387b5d724 100644
--- a/include/sound/hwdep.h
+++ b/include/sound/hwdep.h
@@ -60,7 +60,7 @@ struct snd_hwdep {
60 void *private_data; 60 void *private_data;
61 void (*private_free) (struct snd_hwdep *hwdep); 61 void (*private_free) (struct snd_hwdep *hwdep);
62 62
63 struct semaphore open_mutex; 63 struct mutex open_mutex;
64 int used; 64 int used;
65 unsigned int dsp_loaded; 65 unsigned int dsp_loaded;
66 unsigned int exclusive: 1; 66 unsigned int exclusive: 1;
diff --git a/include/sound/info.h b/include/sound/info.h
index 8ea5c7497c03..f23d8381c216 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -84,7 +84,7 @@ struct snd_info_entry {
84 void *private_data; 84 void *private_data;
85 void (*private_free)(struct snd_info_entry *entry); 85 void (*private_free)(struct snd_info_entry *entry);
86 struct proc_dir_entry *p; 86 struct proc_dir_entry *p;
87 struct semaphore access; 87 struct mutex access;
88}; 88};
89 89
90#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) 90#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
diff --git a/include/sound/mixer_oss.h b/include/sound/mixer_oss.h
index ca5b4822b62c..197b9e3d612b 100644
--- a/include/sound/mixer_oss.h
+++ b/include/sound/mixer_oss.h
@@ -61,7 +61,7 @@ struct snd_mixer_oss {
61 unsigned int active_index); 61 unsigned int active_index);
62 void *private_data_recsrc; 62 void *private_data_recsrc;
63 void (*private_free_recsrc)(struct snd_mixer_oss *mixer); 63 void (*private_free_recsrc)(struct snd_mixer_oss *mixer);
64 struct semaphore reg_mutex; 64 struct mutex reg_mutex;
65 struct snd_info_entry *proc_entry; 65 struct snd_info_entry *proc_entry;
66 int oss_dev_alloc; 66 int oss_dev_alloc;
67 /* --- */ 67 /* --- */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 314268a11048..15b885660bf0 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -420,7 +420,7 @@ struct snd_pcm {
420 char id[64]; 420 char id[64];
421 char name[80]; 421 char name[80];
422 struct snd_pcm_str streams[2]; 422 struct snd_pcm_str streams[2];
423 struct semaphore open_mutex; 423 struct mutex open_mutex;
424 wait_queue_head_t open_wait; 424 wait_queue_head_t open_wait;
425 void *private_data; 425 void *private_data;
426 void (*private_free) (struct snd_pcm *pcm); 426 void (*private_free) (struct snd_pcm *pcm);
diff --git a/include/sound/pcm_oss.h b/include/sound/pcm_oss.h
index d6ec886637db..bff0778e1969 100644
--- a/include/sound/pcm_oss.h
+++ b/include/sound/pcm_oss.h
@@ -75,7 +75,7 @@ struct snd_pcm_oss_substream {
75 75
76struct snd_pcm_oss_stream { 76struct snd_pcm_oss_stream {
77 struct snd_pcm_oss_setup *setup_list; /* setup list */ 77 struct snd_pcm_oss_setup *setup_list; /* setup list */
78 struct semaphore setup_mutex; 78 struct mutex setup_mutex;
79 struct snd_info_entry *proc_entry; 79 struct snd_info_entry *proc_entry;
80}; 80};
81 81
diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h
index d19bddfbf995..584e73dd4793 100644
--- a/include/sound/rawmidi.h
+++ b/include/sound/rawmidi.h
@@ -26,7 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <asm/semaphore.h> 29#include <linux/mutex.h>
30 30
31#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) 31#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
32#include "seq_device.h" 32#include "seq_device.h"
@@ -130,7 +130,7 @@ struct snd_rawmidi {
130 void *private_data; 130 void *private_data;
131 void (*private_free) (struct snd_rawmidi *rmidi); 131 void (*private_free) (struct snd_rawmidi *rmidi);
132 132
133 struct semaphore open_mutex; 133 struct mutex open_mutex;
134 wait_queue_head_t open_wait; 134 wait_queue_head_t open_wait;
135 135
136 struct snd_info_entry *dev; 136 struct snd_info_entry *dev;
diff --git a/include/sound/seq_instr.h b/include/sound/seq_instr.h
index db764f09efb7..f2db03bfd74e 100644
--- a/include/sound/seq_instr.h
+++ b/include/sound/seq_instr.h
@@ -64,7 +64,7 @@ struct snd_seq_kinstr_list {
64 64
65 spinlock_t lock; 65 spinlock_t lock;
66 spinlock_t ops_lock; 66 spinlock_t ops_lock;
67 struct semaphore ops_mutex; 67 struct mutex ops_mutex;
68 unsigned long ops_flags; 68 unsigned long ops_flags;
69}; 69};
70 70
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 618c43be0bc3..2524e66eccdd 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -25,6 +25,7 @@
25#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/mutex.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include <sound/control.h> 30#include <sound/control.h>
30#include <sound/minors.h> 31#include <sound/minors.h>
@@ -36,7 +37,7 @@ MODULE_DESCRIPTION("Hardware dependent layer");
36MODULE_LICENSE("GPL"); 37MODULE_LICENSE("GPL");
37 38
38static LIST_HEAD(snd_hwdep_devices); 39static LIST_HEAD(snd_hwdep_devices);
39static DECLARE_MUTEX(register_mutex); 40static DEFINE_MUTEX(register_mutex);
40 41
41static int snd_hwdep_free(struct snd_hwdep *hwdep); 42static int snd_hwdep_free(struct snd_hwdep *hwdep);
42static int snd_hwdep_dev_free(struct snd_device *device); 43static int snd_hwdep_dev_free(struct snd_device *device);
@@ -111,7 +112,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
111 112
112 init_waitqueue_entry(&wait, current); 113 init_waitqueue_entry(&wait, current);
113 add_wait_queue(&hw->open_wait, &wait); 114 add_wait_queue(&hw->open_wait, &wait);
114 down(&hw->open_mutex); 115 mutex_lock(&hw->open_mutex);
115 while (1) { 116 while (1) {
116 if (hw->exclusive && hw->used > 0) { 117 if (hw->exclusive && hw->used > 0) {
117 err = -EBUSY; 118 err = -EBUSY;
@@ -128,9 +129,9 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
128 } else 129 } else
129 break; 130 break;
130 set_current_state(TASK_INTERRUPTIBLE); 131 set_current_state(TASK_INTERRUPTIBLE);
131 up(&hw->open_mutex); 132 mutex_unlock(&hw->open_mutex);
132 schedule(); 133 schedule();
133 down(&hw->open_mutex); 134 mutex_lock(&hw->open_mutex);
134 if (signal_pending(current)) { 135 if (signal_pending(current)) {
135 err = -ERESTARTSYS; 136 err = -ERESTARTSYS;
136 break; 137 break;
@@ -147,7 +148,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
147 hw->ops.release(hw, file); 148 hw->ops.release(hw, file);
148 } 149 }
149 } 150 }
150 up(&hw->open_mutex); 151 mutex_unlock(&hw->open_mutex);
151 if (err < 0) 152 if (err < 0)
152 module_put(hw->card->module); 153 module_put(hw->card->module);
153 return err; 154 return err;
@@ -157,7 +158,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
157{ 158{
158 int err = -ENXIO; 159 int err = -ENXIO;
159 struct snd_hwdep *hw = file->private_data; 160 struct snd_hwdep *hw = file->private_data;
160 down(&hw->open_mutex); 161 mutex_lock(&hw->open_mutex);
161 if (hw->ops.release) { 162 if (hw->ops.release) {
162 err = hw->ops.release(hw, file); 163 err = hw->ops.release(hw, file);
163 wake_up(&hw->open_wait); 164 wake_up(&hw->open_wait);
@@ -165,7 +166,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
165 if (hw->used > 0) 166 if (hw->used > 0)
166 hw->used--; 167 hw->used--;
167 snd_card_file_remove(hw->card, file); 168 snd_card_file_remove(hw->card, file);
168 up(&hw->open_mutex); 169 mutex_unlock(&hw->open_mutex);
169 module_put(hw->card->module); 170 module_put(hw->card->module);
170 return err; 171 return err;
171} 172}
@@ -272,7 +273,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
272 273
273 if (get_user(device, (int __user *)arg)) 274 if (get_user(device, (int __user *)arg))
274 return -EFAULT; 275 return -EFAULT;
275 down(&register_mutex); 276 mutex_lock(&register_mutex);
276 device = device < 0 ? 0 : device + 1; 277 device = device < 0 ? 0 : device + 1;
277 while (device < SNDRV_MINOR_HWDEPS) { 278 while (device < SNDRV_MINOR_HWDEPS) {
278 if (snd_hwdep_search(card, device)) 279 if (snd_hwdep_search(card, device))
@@ -281,7 +282,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
281 } 282 }
282 if (device >= SNDRV_MINOR_HWDEPS) 283 if (device >= SNDRV_MINOR_HWDEPS)
283 device = -1; 284 device = -1;
284 up(&register_mutex); 285 mutex_unlock(&register_mutex);
285 if (put_user(device, (int __user *)arg)) 286 if (put_user(device, (int __user *)arg))
286 return -EFAULT; 287 return -EFAULT;
287 return 0; 288 return 0;
@@ -294,13 +295,13 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
294 295
295 if (get_user(device, &info->device)) 296 if (get_user(device, &info->device))
296 return -EFAULT; 297 return -EFAULT;
297 down(&register_mutex); 298 mutex_lock(&register_mutex);
298 hwdep = snd_hwdep_search(card, device); 299 hwdep = snd_hwdep_search(card, device);
299 if (hwdep) 300 if (hwdep)
300 err = snd_hwdep_info(hwdep, info); 301 err = snd_hwdep_info(hwdep, info);
301 else 302 else
302 err = -ENXIO; 303 err = -ENXIO;
303 up(&register_mutex); 304 mutex_unlock(&register_mutex);
304 return err; 305 return err;
305 } 306 }
306 } 307 }
@@ -375,7 +376,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,
375 return err; 376 return err;
376 } 377 }
377 init_waitqueue_head(&hwdep->open_wait); 378 init_waitqueue_head(&hwdep->open_wait);
378 init_MUTEX(&hwdep->open_mutex); 379 mutex_init(&hwdep->open_mutex);
379 *rhwdep = hwdep; 380 *rhwdep = hwdep;
380 return 0; 381 return 0;
381} 382}
@@ -401,9 +402,9 @@ static int snd_hwdep_dev_register(struct snd_device *device)
401 int err; 402 int err;
402 char name[32]; 403 char name[32];
403 404
404 down(&register_mutex); 405 mutex_lock(&register_mutex);
405 if (snd_hwdep_search(hwdep->card, hwdep->device)) { 406 if (snd_hwdep_search(hwdep->card, hwdep->device)) {
406 up(&register_mutex); 407 mutex_unlock(&register_mutex);
407 return -EBUSY; 408 return -EBUSY;
408 } 409 }
409 list_add_tail(&hwdep->list, &snd_hwdep_devices); 410 list_add_tail(&hwdep->list, &snd_hwdep_devices);
@@ -414,7 +415,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
414 snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", 415 snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
415 hwdep->card->number, hwdep->device); 416 hwdep->card->number, hwdep->device);
416 list_del(&hwdep->list); 417 list_del(&hwdep->list);
417 up(&register_mutex); 418 mutex_unlock(&register_mutex);
418 return err; 419 return err;
419 } 420 }
420#ifdef CONFIG_SND_OSSEMUL 421#ifdef CONFIG_SND_OSSEMUL
@@ -434,7 +435,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
434 } 435 }
435 } 436 }
436#endif 437#endif
437 up(&register_mutex); 438 mutex_unlock(&register_mutex);
438 return 0; 439 return 0;
439} 440}
440 441
@@ -443,9 +444,9 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
443 struct snd_hwdep *hwdep = device->device_data; 444 struct snd_hwdep *hwdep = device->device_data;
444 445
445 snd_assert(hwdep != NULL, return -ENXIO); 446 snd_assert(hwdep != NULL, return -ENXIO);
446 down(&register_mutex); 447 mutex_lock(&register_mutex);
447 if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { 448 if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) {
448 up(&register_mutex); 449 mutex_unlock(&register_mutex);
449 return -EINVAL; 450 return -EINVAL;
450 } 451 }
451#ifdef CONFIG_SND_OSSEMUL 452#ifdef CONFIG_SND_OSSEMUL
@@ -454,7 +455,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device)
454#endif 455#endif
455 snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); 456 snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device);
456 list_del(&hwdep->list); 457 list_del(&hwdep->list);
457 up(&register_mutex); 458 mutex_unlock(&register_mutex);
458 return snd_hwdep_free(hwdep); 459 return snd_hwdep_free(hwdep);
459} 460}
460 461
@@ -469,13 +470,13 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry,
469 struct list_head *p; 470 struct list_head *p;
470 struct snd_hwdep *hwdep; 471 struct snd_hwdep *hwdep;
471 472
472 down(&register_mutex); 473 mutex_lock(&register_mutex);
473 list_for_each(p, &snd_hwdep_devices) { 474 list_for_each(p, &snd_hwdep_devices) {
474 hwdep = list_entry(p, struct snd_hwdep, list); 475 hwdep = list_entry(p, struct snd_hwdep, list);
475 snd_iprintf(buffer, "%02i-%02i: %s\n", 476 snd_iprintf(buffer, "%02i-%02i: %s\n",
476 hwdep->card->number, hwdep->device, hwdep->name); 477 hwdep->card->number, hwdep->device, hwdep->name);
477 } 478 }
478 up(&register_mutex); 479 mutex_unlock(&register_mutex);
479} 480}
480 481
481static struct snd_info_entry *snd_hwdep_proc_entry; 482static struct snd_info_entry *snd_hwdep_proc_entry;
diff --git a/sound/core/info.c b/sound/core/info.c
index af123e3bdb24..2582b74d3199 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -31,6 +31,7 @@
31#include <sound/version.h> 31#include <sound/version.h>
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/devfs_fs_kernel.h> 33#include <linux/devfs_fs_kernel.h>
34#include <linux/mutex.h>
34#include <stdarg.h> 35#include <stdarg.h>
35 36
36/* 37/*
@@ -68,7 +69,7 @@ int snd_info_check_reserved_words(const char *str)
68 return 1; 69 return 1;
69} 70}
70 71
71static DECLARE_MUTEX(info_mutex); 72static DEFINE_MUTEX(info_mutex);
72 73
73struct snd_info_private_data { 74struct snd_info_private_data {
74 struct snd_info_buffer *rbuffer; 75 struct snd_info_buffer *rbuffer;
@@ -265,11 +266,11 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
265 struct proc_dir_entry *p; 266 struct proc_dir_entry *p;
266 int mode, err; 267 int mode, err;
267 268
268 down(&info_mutex); 269 mutex_lock(&info_mutex);
269 p = PDE(inode); 270 p = PDE(inode);
270 entry = p == NULL ? NULL : (struct snd_info_entry *)p->data; 271 entry = p == NULL ? NULL : (struct snd_info_entry *)p->data;
271 if (entry == NULL || entry->disconnected) { 272 if (entry == NULL || entry->disconnected) {
272 up(&info_mutex); 273 mutex_unlock(&info_mutex);
273 return -ENODEV; 274 return -ENODEV;
274 } 275 }
275 if (!try_module_get(entry->module)) { 276 if (!try_module_get(entry->module)) {
@@ -361,13 +362,13 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
361 break; 362 break;
362 } 363 }
363 file->private_data = data; 364 file->private_data = data;
364 up(&info_mutex); 365 mutex_unlock(&info_mutex);
365 if (entry->content == SNDRV_INFO_CONTENT_TEXT && 366 if (entry->content == SNDRV_INFO_CONTENT_TEXT &&
366 (mode == O_RDONLY || mode == O_RDWR)) { 367 (mode == O_RDONLY || mode == O_RDWR)) {
367 if (entry->c.text.read) { 368 if (entry->c.text.read) {
368 down(&entry->access); 369 mutex_lock(&entry->access);
369 entry->c.text.read(entry, data->rbuffer); 370 entry->c.text.read(entry, data->rbuffer);
370 up(&entry->access); 371 mutex_unlock(&entry->access);
371 } 372 }
372 } 373 }
373 return 0; 374 return 0;
@@ -375,7 +376,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
375 __error: 376 __error:
376 module_put(entry->module); 377 module_put(entry->module);
377 __error1: 378 __error1:
378 up(&info_mutex); 379 mutex_unlock(&info_mutex);
379 return err; 380 return err;
380} 381}
381 382
@@ -747,7 +748,7 @@ static struct snd_info_entry *snd_info_create_entry(const char *name)
747 } 748 }
748 entry->mode = S_IFREG | S_IRUGO; 749 entry->mode = S_IFREG | S_IRUGO;
749 entry->content = SNDRV_INFO_CONTENT_TEXT; 750 entry->content = SNDRV_INFO_CONTENT_TEXT;
750 init_MUTEX(&entry->access); 751 mutex_init(&entry->access);
751 return entry; 752 return entry;
752} 753}
753 754
@@ -896,10 +897,10 @@ int snd_info_register(struct snd_info_entry * entry)
896 897
897 snd_assert(entry != NULL, return -ENXIO); 898 snd_assert(entry != NULL, return -ENXIO);
898 root = entry->parent == NULL ? snd_proc_root : entry->parent->p; 899 root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
899 down(&info_mutex); 900 mutex_lock(&info_mutex);
900 p = snd_create_proc_entry(entry->name, entry->mode, root); 901 p = snd_create_proc_entry(entry->name, entry->mode, root);
901 if (!p) { 902 if (!p) {
902 up(&info_mutex); 903 mutex_unlock(&info_mutex);
903 return -ENOMEM; 904 return -ENOMEM;
904 } 905 }
905 p->owner = entry->module; 906 p->owner = entry->module;
@@ -908,7 +909,7 @@ int snd_info_register(struct snd_info_entry * entry)
908 p->size = entry->size; 909 p->size = entry->size;
909 p->data = entry; 910 p->data = entry;
910 entry->p = p; 911 entry->p = p;
911 up(&info_mutex); 912 mutex_unlock(&info_mutex);
912 return 0; 913 return 0;
913} 914}
914 915
@@ -929,9 +930,9 @@ int snd_info_unregister(struct snd_info_entry * entry)
929 snd_assert(entry->p != NULL, return -ENXIO); 930 snd_assert(entry->p != NULL, return -ENXIO);
930 root = entry->parent == NULL ? snd_proc_root : entry->parent->p; 931 root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
931 snd_assert(root, return -ENXIO); 932 snd_assert(root, return -ENXIO);
932 down(&info_mutex); 933 mutex_lock(&info_mutex);
933 snd_remove_proc_entry(root, entry->p); 934 snd_remove_proc_entry(root, entry->p);
934 up(&info_mutex); 935 mutex_unlock(&info_mutex);
935 snd_info_free_entry(entry); 936 snd_info_free_entry(entry);
936 return 0; 937 return 0;
937} 938}
diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c
index 820f4772e44a..f9ce854b3d11 100644
--- a/sound/core/info_oss.c
+++ b/sound/core/info_oss.c
@@ -28,6 +28,7 @@
28#include <sound/info.h> 28#include <sound/info.h>
29#include <sound/version.h> 29#include <sound/version.h>
30#include <linux/utsname.h> 30#include <linux/utsname.h>
31#include <linux/mutex.h>
31 32
32#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) 33#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
33 34
@@ -35,7 +36,7 @@
35 * OSS compatible part 36 * OSS compatible part
36 */ 37 */
37 38
38static DECLARE_MUTEX(strings); 39static DEFINE_MUTEX(strings);
39static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT]; 40static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
40static struct snd_info_entry *snd_sndstat_proc_entry; 41static struct snd_info_entry *snd_sndstat_proc_entry;
41 42
@@ -45,7 +46,7 @@ int snd_oss_info_register(int dev, int num, char *string)
45 46
46 snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO); 47 snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO);
47 snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO); 48 snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO);
48 down(&strings); 49 mutex_lock(&strings);
49 if (string == NULL) { 50 if (string == NULL) {
50 if ((x = snd_sndstat_strings[num][dev]) != NULL) { 51 if ((x = snd_sndstat_strings[num][dev]) != NULL) {
51 kfree(x); 52 kfree(x);
@@ -54,12 +55,12 @@ int snd_oss_info_register(int dev, int num, char *string)
54 } else { 55 } else {
55 x = kstrdup(string, GFP_KERNEL); 56 x = kstrdup(string, GFP_KERNEL);
56 if (x == NULL) { 57 if (x == NULL) {
57 up(&strings); 58 mutex_unlock(&strings);
58 return -ENOMEM; 59 return -ENOMEM;
59 } 60 }
60 } 61 }
61 snd_sndstat_strings[num][dev] = x; 62 snd_sndstat_strings[num][dev] = x;
62 up(&strings); 63 mutex_unlock(&strings);
63 return 0; 64 return 0;
64} 65}
65 66
@@ -71,7 +72,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d
71 char *str; 72 char *str;
72 73
73 snd_iprintf(buf, "\n%s:", id); 74 snd_iprintf(buf, "\n%s:", id);
74 down(&strings); 75 mutex_lock(&strings);
75 for (idx = 0; idx < SNDRV_CARDS; idx++) { 76 for (idx = 0; idx < SNDRV_CARDS; idx++) {
76 str = snd_sndstat_strings[idx][dev]; 77 str = snd_sndstat_strings[idx][dev];
77 if (str) { 78 if (str) {
@@ -82,7 +83,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d
82 snd_iprintf(buf, "%i: %s\n", idx, str); 83 snd_iprintf(buf, "%i: %s\n", idx, str);
83 } 84 }
84 } 85 }
85 up(&strings); 86 mutex_unlock(&strings);
86 if (ok < 0) 87 if (ok < 0)
87 snd_iprintf(buf, " NOT ENABLED IN CONFIG\n"); 88 snd_iprintf(buf, " NOT ENABLED IN CONFIG\n");
88 return ok; 89 return ok;
diff --git a/sound/core/init.c b/sound/core/init.c
index 75816688607c..17fbd6c14fb8 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -145,7 +145,7 @@ struct snd_card *snd_card_new(int idx, const char *xid,
145 init_waitqueue_head(&card->shutdown_sleep); 145 init_waitqueue_head(&card->shutdown_sleep);
146 INIT_WORK(&card->free_workq, snd_card_free_thread, card); 146 INIT_WORK(&card->free_workq, snd_card_free_thread, card);
147#ifdef CONFIG_PM 147#ifdef CONFIG_PM
148 init_MUTEX(&card->power_lock); 148 mutex_init(&card->power_lock);
149 init_waitqueue_head(&card->power_sleep); 149 init_waitqueue_head(&card->power_sleep);
150#endif 150#endif
151 /* the control interface cannot be accessed from the user space until */ 151 /* the control interface cannot be accessed from the user space until */
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 19b3dcbb09c2..9f2b88cb5877 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -31,7 +31,7 @@
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <asm/semaphore.h> 34#include <linux/mutex.h>
35#include <sound/memalloc.h> 35#include <sound/memalloc.h>
36#ifdef CONFIG_SBUS 36#ifdef CONFIG_SBUS
37#include <asm/sbus.h> 37#include <asm/sbus.h>
@@ -54,7 +54,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab);
54/* 54/*
55 */ 55 */
56 56
57static DECLARE_MUTEX(list_mutex); 57static DEFINE_MUTEX(list_mutex);
58static LIST_HEAD(mem_list_head); 58static LIST_HEAD(mem_list_head);
59 59
60/* buffer preservation list */ 60/* buffer preservation list */
@@ -440,7 +440,7 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
440 440
441 snd_assert(dmab, return 0); 441 snd_assert(dmab, return 0);
442 442
443 down(&list_mutex); 443 mutex_lock(&list_mutex);
444 list_for_each(p, &mem_list_head) { 444 list_for_each(p, &mem_list_head) {
445 mem = list_entry(p, struct snd_mem_list, list); 445 mem = list_entry(p, struct snd_mem_list, list);
446 if (mem->id == id && 446 if (mem->id == id &&
@@ -452,11 +452,11 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
452 if (dmab->dev.dev == NULL) 452 if (dmab->dev.dev == NULL)
453 dmab->dev.dev = dev; 453 dmab->dev.dev = dev;
454 kfree(mem); 454 kfree(mem);
455 up(&list_mutex); 455 mutex_unlock(&list_mutex);
456 return dmab->bytes; 456 return dmab->bytes;
457 } 457 }
458 } 458 }
459 up(&list_mutex); 459 mutex_unlock(&list_mutex);
460 return 0; 460 return 0;
461} 461}
462 462
@@ -477,11 +477,11 @@ int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id)
477 mem = kmalloc(sizeof(*mem), GFP_KERNEL); 477 mem = kmalloc(sizeof(*mem), GFP_KERNEL);
478 if (! mem) 478 if (! mem)
479 return -ENOMEM; 479 return -ENOMEM;
480 down(&list_mutex); 480 mutex_lock(&list_mutex);
481 mem->buffer = *dmab; 481 mem->buffer = *dmab;
482 mem->id = id; 482 mem->id = id;
483 list_add_tail(&mem->list, &mem_list_head); 483 list_add_tail(&mem->list, &mem_list_head);
484 up(&list_mutex); 484 mutex_unlock(&list_mutex);
485 return 0; 485 return 0;
486} 486}
487 487
@@ -493,7 +493,7 @@ static void free_all_reserved_pages(void)
493 struct list_head *p; 493 struct list_head *p;
494 struct snd_mem_list *mem; 494 struct snd_mem_list *mem;
495 495
496 down(&list_mutex); 496 mutex_lock(&list_mutex);
497 while (! list_empty(&mem_list_head)) { 497 while (! list_empty(&mem_list_head)) {
498 p = mem_list_head.next; 498 p = mem_list_head.next;
499 mem = list_entry(p, struct snd_mem_list, list); 499 mem = list_entry(p, struct snd_mem_list, list);
@@ -501,7 +501,7 @@ static void free_all_reserved_pages(void)
501 snd_dma_free_pages(&mem->buffer); 501 snd_dma_free_pages(&mem->buffer);
502 kfree(mem); 502 kfree(mem);
503 } 503 }
504 up(&list_mutex); 504 mutex_unlock(&list_mutex);
505} 505}
506 506
507 507
@@ -522,7 +522,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
522 int devno; 522 int devno;
523 static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; 523 static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
524 524
525 down(&list_mutex); 525 mutex_lock(&list_mutex);
526 len += snprintf(page + len, count - len, 526 len += snprintf(page + len, count - len,
527 "pages : %li bytes (%li pages per %likB)\n", 527 "pages : %li bytes (%li pages per %likB)\n",
528 pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); 528 pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
@@ -537,7 +537,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
537 " addr = 0x%lx, size = %d bytes\n", 537 " addr = 0x%lx, size = %d bytes\n",
538 (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes); 538 (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes);
539 } 539 }
540 up(&list_mutex); 540 mutex_unlock(&list_mutex);
541 return len; 541 return len;
542} 542}
543 543
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index f08e65a2bffe..9c68bc3f97aa 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -1095,7 +1095,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry,
1095 struct snd_mixer_oss *mixer = entry->private_data; 1095 struct snd_mixer_oss *mixer = entry->private_data;
1096 int i; 1096 int i;
1097 1097
1098 down(&mixer->reg_mutex); 1098 mutex_lock(&mixer->reg_mutex);
1099 for (i = 0; i < SNDRV_OSS_MAX_MIXERS; i++) { 1099 for (i = 0; i < SNDRV_OSS_MAX_MIXERS; i++) {
1100 struct slot *p; 1100 struct slot *p;
1101 1101
@@ -1110,7 +1110,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry,
1110 else 1110 else
1111 snd_iprintf(buffer, "\"\" 0\n"); 1111 snd_iprintf(buffer, "\"\" 0\n");
1112 } 1112 }
1113 up(&mixer->reg_mutex); 1113 mutex_unlock(&mixer->reg_mutex);
1114} 1114}
1115 1115
1116static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, 1116static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
@@ -1134,9 +1134,9 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
1134 cptr = snd_info_get_str(str, cptr, sizeof(str)); 1134 cptr = snd_info_get_str(str, cptr, sizeof(str));
1135 if (! *str) { 1135 if (! *str) {
1136 /* remove the entry */ 1136 /* remove the entry */
1137 down(&mixer->reg_mutex); 1137 mutex_lock(&mixer->reg_mutex);
1138 mixer_slot_clear(&mixer->slots[ch]); 1138 mixer_slot_clear(&mixer->slots[ch]);
1139 up(&mixer->reg_mutex); 1139 mutex_unlock(&mixer->reg_mutex);
1140 continue; 1140 continue;
1141 } 1141 }
1142 snd_info_get_str(idxstr, cptr, sizeof(idxstr)); 1142 snd_info_get_str(idxstr, cptr, sizeof(idxstr));
@@ -1145,7 +1145,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
1145 snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx); 1145 snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx);
1146 continue; 1146 continue;
1147 } 1147 }
1148 down(&mixer->reg_mutex); 1148 mutex_lock(&mixer->reg_mutex);
1149 slot = (struct slot *)mixer->slots[ch].private_data; 1149 slot = (struct slot *)mixer->slots[ch].private_data;
1150 if (slot && slot->assigned && 1150 if (slot && slot->assigned &&
1151 slot->assigned->index == idx && ! strcmp(slot->assigned->name, str)) 1151 slot->assigned->index == idx && ! strcmp(slot->assigned->name, str))
@@ -1168,7 +1168,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
1168 kfree(tbl); 1168 kfree(tbl);
1169 } 1169 }
1170 __unlock: 1170 __unlock:
1171 up(&mixer->reg_mutex); 1171 mutex_unlock(&mixer->reg_mutex);
1172 } 1172 }
1173} 1173}
1174 1174
@@ -1288,7 +1288,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
1288 mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL); 1288 mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL);
1289 if (mixer == NULL) 1289 if (mixer == NULL)
1290 return -ENOMEM; 1290 return -ENOMEM;
1291 init_MUTEX(&mixer->reg_mutex); 1291 mutex_init(&mixer->reg_mutex);
1292 sprintf(name, "mixer%i%i", card->number, 0); 1292 sprintf(name, "mixer%i%i", card->number, 0);
1293 if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, 1293 if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
1294 card, 0, 1294 card, 0,
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index bc24d028f518..f8302b703a30 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1643,10 +1643,10 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm,
1643 const char *ptr, *ptrl; 1643 const char *ptr, *ptrl;
1644 struct snd_pcm_oss_setup *setup; 1644 struct snd_pcm_oss_setup *setup;
1645 1645
1646 down(&pcm->streams[stream].oss.setup_mutex); 1646 mutex_lock(&pcm->streams[stream].oss.setup_mutex);
1647 for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { 1647 for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) {
1648 if (!strcmp(setup->task_name, task_name)) { 1648 if (!strcmp(setup->task_name, task_name)) {
1649 up(&pcm->streams[stream].oss.setup_mutex); 1649 mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
1650 return setup; 1650 return setup;
1651 } 1651 }
1652 } 1652 }
@@ -1662,12 +1662,12 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm,
1662 } 1662 }
1663 for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { 1663 for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) {
1664 if (!strcmp(setup->task_name, ptrl)) { 1664 if (!strcmp(setup->task_name, ptrl)) {
1665 up(&pcm->streams[stream].oss.setup_mutex); 1665 mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
1666 return setup; 1666 return setup;
1667 } 1667 }
1668 } 1668 }
1669 __not_found: 1669 __not_found:
1670 up(&pcm->streams[stream].oss.setup_mutex); 1670 mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
1671 return NULL; 1671 return NULL;
1672} 1672}
1673 1673
@@ -1895,7 +1895,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
1895 1895
1896 init_waitqueue_entry(&wait, current); 1896 init_waitqueue_entry(&wait, current);
1897 add_wait_queue(&pcm->open_wait, &wait); 1897 add_wait_queue(&pcm->open_wait, &wait);
1898 down(&pcm->open_mutex); 1898 mutex_lock(&pcm->open_mutex);
1899 while (1) { 1899 while (1) {
1900 err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, 1900 err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file,
1901 iminor(inode), psetup, csetup); 1901 iminor(inode), psetup, csetup);
@@ -1909,16 +1909,16 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
1909 } else 1909 } else
1910 break; 1910 break;
1911 set_current_state(TASK_INTERRUPTIBLE); 1911 set_current_state(TASK_INTERRUPTIBLE);
1912 up(&pcm->open_mutex); 1912 mutex_unlock(&pcm->open_mutex);
1913 schedule(); 1913 schedule();
1914 down(&pcm->open_mutex); 1914 mutex_lock(&pcm->open_mutex);
1915 if (signal_pending(current)) { 1915 if (signal_pending(current)) {
1916 err = -ERESTARTSYS; 1916 err = -ERESTARTSYS;
1917 break; 1917 break;
1918 } 1918 }
1919 } 1919 }
1920 remove_wait_queue(&pcm->open_wait, &wait); 1920 remove_wait_queue(&pcm->open_wait, &wait);
1921 up(&pcm->open_mutex); 1921 mutex_unlock(&pcm->open_mutex);
1922 if (err < 0) 1922 if (err < 0)
1923 goto __error; 1923 goto __error;
1924 return err; 1924 return err;
@@ -1944,9 +1944,9 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
1944 snd_assert(substream != NULL, return -ENXIO); 1944 snd_assert(substream != NULL, return -ENXIO);
1945 pcm = substream->pcm; 1945 pcm = substream->pcm;
1946 snd_pcm_oss_sync(pcm_oss_file); 1946 snd_pcm_oss_sync(pcm_oss_file);
1947 down(&pcm->open_mutex); 1947 mutex_lock(&pcm->open_mutex);
1948 snd_pcm_oss_release_file(pcm_oss_file); 1948 snd_pcm_oss_release_file(pcm_oss_file);
1949 up(&pcm->open_mutex); 1949 mutex_unlock(&pcm->open_mutex);
1950 wake_up(&pcm->open_wait); 1950 wake_up(&pcm->open_wait);
1951 module_put(pcm->card->module); 1951 module_put(pcm->card->module);
1952 snd_card_file_remove(pcm->card, file); 1952 snd_card_file_remove(pcm->card, file);
@@ -2293,7 +2293,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
2293{ 2293{
2294 struct snd_pcm_str *pstr = entry->private_data; 2294 struct snd_pcm_str *pstr = entry->private_data;
2295 struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; 2295 struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
2296 down(&pstr->oss.setup_mutex); 2296 mutex_lock(&pstr->oss.setup_mutex);
2297 while (setup) { 2297 while (setup) {
2298 snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", 2298 snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
2299 setup->task_name, 2299 setup->task_name,
@@ -2307,7 +2307,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
2307 setup->nosilence ? " no-silence" : ""); 2307 setup->nosilence ? " no-silence" : "");
2308 setup = setup->next; 2308 setup = setup->next;
2309 } 2309 }
2310 up(&pstr->oss.setup_mutex); 2310 mutex_unlock(&pstr->oss.setup_mutex);
2311} 2311}
2312 2312
2313static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr) 2313static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr)
@@ -2337,12 +2337,12 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
2337 struct snd_pcm_oss_setup *setup, *setup1, template; 2337 struct snd_pcm_oss_setup *setup, *setup1, template;
2338 2338
2339 while (!snd_info_get_line(buffer, line, sizeof(line))) { 2339 while (!snd_info_get_line(buffer, line, sizeof(line))) {
2340 down(&pstr->oss.setup_mutex); 2340 mutex_lock(&pstr->oss.setup_mutex);
2341 memset(&template, 0, sizeof(template)); 2341 memset(&template, 0, sizeof(template));
2342 ptr = snd_info_get_str(task_name, line, sizeof(task_name)); 2342 ptr = snd_info_get_str(task_name, line, sizeof(task_name));
2343 if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) { 2343 if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
2344 snd_pcm_oss_proc_free_setup_list(pstr); 2344 snd_pcm_oss_proc_free_setup_list(pstr);
2345 up(&pstr->oss.setup_mutex); 2345 mutex_unlock(&pstr->oss.setup_mutex);
2346 continue; 2346 continue;
2347 } 2347 }
2348 for (setup = pstr->oss.setup_list; setup; setup = setup->next) { 2348 for (setup = pstr->oss.setup_list; setup; setup = setup->next) {
@@ -2394,7 +2394,7 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
2394 } 2394 }
2395 if (setup) 2395 if (setup)
2396 *setup = template; 2396 *setup = template;
2397 up(&pstr->oss.setup_mutex); 2397 mutex_unlock(&pstr->oss.setup_mutex);
2398 } 2398 }
2399} 2399}
2400 2400
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index d92c3ce4a4c9..f903d1bd74d5 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/mutex.h>
26#include <sound/core.h> 27#include <sound/core.h>
27#include <sound/minors.h> 28#include <sound/minors.h>
28#include <sound/pcm.h> 29#include <sound/pcm.h>
@@ -35,7 +36,7 @@ MODULE_LICENSE("GPL");
35 36
36static LIST_HEAD(snd_pcm_devices); 37static LIST_HEAD(snd_pcm_devices);
37static LIST_HEAD(snd_pcm_notify_list); 38static LIST_HEAD(snd_pcm_notify_list);
38static DECLARE_MUTEX(register_mutex); 39static DEFINE_MUTEX(register_mutex);
39 40
40static int snd_pcm_free(struct snd_pcm *pcm); 41static int snd_pcm_free(struct snd_pcm *pcm);
41static int snd_pcm_dev_free(struct snd_device *device); 42static int snd_pcm_dev_free(struct snd_device *device);
@@ -67,7 +68,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
67 68
68 if (get_user(device, (int __user *)arg)) 69 if (get_user(device, (int __user *)arg))
69 return -EFAULT; 70 return -EFAULT;
70 down(&register_mutex); 71 mutex_lock(&register_mutex);
71 device = device < 0 ? 0 : device + 1; 72 device = device < 0 ? 0 : device + 1;
72 while (device < SNDRV_PCM_DEVICES) { 73 while (device < SNDRV_PCM_DEVICES) {
73 if (snd_pcm_search(card, device)) 74 if (snd_pcm_search(card, device))
@@ -76,7 +77,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
76 } 77 }
77 if (device == SNDRV_PCM_DEVICES) 78 if (device == SNDRV_PCM_DEVICES)
78 device = -1; 79 device = -1;
79 up(&register_mutex); 80 mutex_unlock(&register_mutex);
80 if (put_user(device, (int __user *)arg)) 81 if (put_user(device, (int __user *)arg))
81 return -EFAULT; 82 return -EFAULT;
82 return 0; 83 return 0;
@@ -100,7 +101,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
100 return -EINVAL; 101 return -EINVAL;
101 if (get_user(subdevice, &info->subdevice)) 102 if (get_user(subdevice, &info->subdevice))
102 return -EFAULT; 103 return -EFAULT;
103 down(&register_mutex); 104 mutex_lock(&register_mutex);
104 pcm = snd_pcm_search(card, device); 105 pcm = snd_pcm_search(card, device);
105 if (pcm == NULL) { 106 if (pcm == NULL) {
106 err = -ENXIO; 107 err = -ENXIO;
@@ -125,7 +126,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
125 } 126 }
126 err = snd_pcm_info_user(substream, info); 127 err = snd_pcm_info_user(substream, info);
127 _error: 128 _error:
128 up(&register_mutex); 129 mutex_unlock(&register_mutex);
129 return err; 130 return err;
130 } 131 }
131 case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE: 132 case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE:
@@ -262,6 +263,7 @@ static const char *snd_pcm_state_name(snd_pcm_state_t state)
262 263
263#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) 264#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
264#include <linux/soundcard.h> 265#include <linux/soundcard.h>
266
265static const char *snd_pcm_oss_format_name(int format) 267static const char *snd_pcm_oss_format_name(int format)
266{ 268{
267 switch (format) { 269 switch (format) {
@@ -624,7 +626,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
624 struct snd_pcm_substream *substream, *prev; 626 struct snd_pcm_substream *substream, *prev;
625 627
626#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) 628#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
627 init_MUTEX(&pstr->oss.setup_mutex); 629 mutex_init(&pstr->oss.setup_mutex);
628#endif 630#endif
629 pstr->stream = stream; 631 pstr->stream = stream;
630 pstr->pcm = pcm; 632 pstr->pcm = pcm;
@@ -718,7 +720,7 @@ int snd_pcm_new(struct snd_card *card, char *id, int device,
718 snd_pcm_free(pcm); 720 snd_pcm_free(pcm);
719 return err; 721 return err;
720 } 722 }
721 init_MUTEX(&pcm->open_mutex); 723 mutex_init(&pcm->open_mutex);
722 init_waitqueue_head(&pcm->open_wait); 724 init_waitqueue_head(&pcm->open_wait);
723 if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) { 725 if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) {
724 snd_pcm_free(pcm); 726 snd_pcm_free(pcm);
@@ -904,9 +906,9 @@ static int snd_pcm_dev_register(struct snd_device *device)
904 struct snd_pcm *pcm = device->device_data; 906 struct snd_pcm *pcm = device->device_data;
905 907
906 snd_assert(pcm != NULL && device != NULL, return -ENXIO); 908 snd_assert(pcm != NULL && device != NULL, return -ENXIO);
907 down(&register_mutex); 909 mutex_lock(&register_mutex);
908 if (snd_pcm_search(pcm->card, pcm->device)) { 910 if (snd_pcm_search(pcm->card, pcm->device)) {
909 up(&register_mutex); 911 mutex_unlock(&register_mutex);
910 return -EBUSY; 912 return -EBUSY;
911 } 913 }
912 list_add_tail(&pcm->list, &snd_pcm_devices); 914 list_add_tail(&pcm->list, &snd_pcm_devices);
@@ -930,7 +932,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
930 pcm, str)) < 0) 932 pcm, str)) < 0)
931 { 933 {
932 list_del(&pcm->list); 934 list_del(&pcm->list);
933 up(&register_mutex); 935 mutex_unlock(&register_mutex);
934 return err; 936 return err;
935 } 937 }
936 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 938 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
@@ -941,7 +943,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
941 notify = list_entry(list, struct snd_pcm_notify, list); 943 notify = list_entry(list, struct snd_pcm_notify, list);
942 notify->n_register(pcm); 944 notify->n_register(pcm);
943 } 945 }
944 up(&register_mutex); 946 mutex_unlock(&register_mutex);
945 return 0; 947 return 0;
946} 948}
947 949
@@ -952,7 +954,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
952 struct snd_pcm_substream *substream; 954 struct snd_pcm_substream *substream;
953 int cidx; 955 int cidx;
954 956
955 down(&register_mutex); 957 mutex_lock(&register_mutex);
956 list_del_init(&pcm->list); 958 list_del_init(&pcm->list);
957 for (cidx = 0; cidx < 2; cidx++) 959 for (cidx = 0; cidx < 2; cidx++)
958 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 960 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
@@ -963,7 +965,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
963 notify = list_entry(list, struct snd_pcm_notify, list); 965 notify = list_entry(list, struct snd_pcm_notify, list);
964 notify->n_disconnect(pcm); 966 notify->n_disconnect(pcm);
965 } 967 }
966 up(&register_mutex); 968 mutex_unlock(&register_mutex);
967 return 0; 969 return 0;
968} 970}
969 971
@@ -975,7 +977,7 @@ static int snd_pcm_dev_unregister(struct snd_device *device)
975 struct snd_pcm *pcm = device->device_data; 977 struct snd_pcm *pcm = device->device_data;
976 978
977 snd_assert(pcm != NULL, return -ENXIO); 979 snd_assert(pcm != NULL, return -ENXIO);
978 down(&register_mutex); 980 mutex_lock(&register_mutex);
979 list_del(&pcm->list); 981 list_del(&pcm->list);
980 for (cidx = 0; cidx < 2; cidx++) { 982 for (cidx = 0; cidx < 2; cidx++) {
981 devtype = -1; 983 devtype = -1;
@@ -996,7 +998,7 @@ static int snd_pcm_dev_unregister(struct snd_device *device)
996 notify = list_entry(list, struct snd_pcm_notify, list); 998 notify = list_entry(list, struct snd_pcm_notify, list);
997 notify->n_unregister(pcm); 999 notify->n_unregister(pcm);
998 } 1000 }
999 up(&register_mutex); 1001 mutex_unlock(&register_mutex);
1000 return snd_pcm_free(pcm); 1002 return snd_pcm_free(pcm);
1001} 1003}
1002 1004
@@ -1005,7 +1007,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
1005 struct list_head *p; 1007 struct list_head *p;
1006 1008
1007 snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL); 1009 snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL);
1008 down(&register_mutex); 1010 mutex_lock(&register_mutex);
1009 if (nfree) { 1011 if (nfree) {
1010 list_del(&notify->list); 1012 list_del(&notify->list);
1011 list_for_each(p, &snd_pcm_devices) 1013 list_for_each(p, &snd_pcm_devices)
@@ -1016,7 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
1016 list_for_each(p, &snd_pcm_devices) 1018 list_for_each(p, &snd_pcm_devices)
1017 notify->n_register(list_entry(p, struct snd_pcm, list)); 1019 notify->n_register(list_entry(p, struct snd_pcm, list));
1018 } 1020 }
1019 up(&register_mutex); 1021 mutex_unlock(&register_mutex);
1020 return 0; 1022 return 0;
1021} 1023}
1022 1024
@@ -1031,7 +1033,7 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry,
1031 struct list_head *p; 1033 struct list_head *p;
1032 struct snd_pcm *pcm; 1034 struct snd_pcm *pcm;
1033 1035
1034 down(&register_mutex); 1036 mutex_lock(&register_mutex);
1035 list_for_each(p, &snd_pcm_devices) { 1037 list_for_each(p, &snd_pcm_devices) {
1036 pcm = list_entry(p, struct snd_pcm, list); 1038 pcm = list_entry(p, struct snd_pcm, list);
1037 snd_iprintf(buffer, "%02i-%02i: %s : %s", 1039 snd_iprintf(buffer, "%02i-%02i: %s : %s",
@@ -1044,7 +1046,7 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry,
1044 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count); 1046 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count);
1045 snd_iprintf(buffer, "\n"); 1047 snd_iprintf(buffer, "\n");
1046 } 1048 }
1047 up(&register_mutex); 1049 mutex_unlock(&register_mutex);
1048} 1050}
1049 1051
1050static struct snd_info_entry *snd_pcm_proc_entry = NULL; 1052static struct snd_info_entry *snd_pcm_proc_entry = NULL;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index f3d5de7b55ac..ce1956a5528d 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2112,7 +2112,7 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
2112 } 2112 }
2113 init_waitqueue_entry(&wait, current); 2113 init_waitqueue_entry(&wait, current);
2114 add_wait_queue(&pcm->open_wait, &wait); 2114 add_wait_queue(&pcm->open_wait, &wait);
2115 down(&pcm->open_mutex); 2115 mutex_lock(&pcm->open_mutex);
2116 while (1) { 2116 while (1) {
2117 err = snd_pcm_open_file(file, pcm, stream, &pcm_file); 2117 err = snd_pcm_open_file(file, pcm, stream, &pcm_file);
2118 if (err >= 0) 2118 if (err >= 0)
@@ -2125,16 +2125,16 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
2125 } else 2125 } else
2126 break; 2126 break;
2127 set_current_state(TASK_INTERRUPTIBLE); 2127 set_current_state(TASK_INTERRUPTIBLE);
2128 up(&pcm->open_mutex); 2128 mutex_unlock(&pcm->open_mutex);
2129 schedule(); 2129 schedule();
2130 down(&pcm->open_mutex); 2130 mutex_lock(&pcm->open_mutex);
2131 if (signal_pending(current)) { 2131 if (signal_pending(current)) {
2132 err = -ERESTARTSYS; 2132 err = -ERESTARTSYS;
2133 break; 2133 break;
2134 } 2134 }
2135 } 2135 }
2136 remove_wait_queue(&pcm->open_wait, &wait); 2136 remove_wait_queue(&pcm->open_wait, &wait);
2137 up(&pcm->open_mutex); 2137 mutex_unlock(&pcm->open_mutex);
2138 if (err < 0) 2138 if (err < 0)
2139 goto __error; 2139 goto __error;
2140 return err; 2140 return err;
@@ -2160,9 +2160,9 @@ static int snd_pcm_release(struct inode *inode, struct file *file)
2160 pcm = substream->pcm; 2160 pcm = substream->pcm;
2161 snd_pcm_drop(substream); 2161 snd_pcm_drop(substream);
2162 fasync_helper(-1, file, 0, &substream->runtime->fasync); 2162 fasync_helper(-1, file, 0, &substream->runtime->fasync);
2163 down(&pcm->open_mutex); 2163 mutex_lock(&pcm->open_mutex);
2164 snd_pcm_release_file(pcm_file); 2164 snd_pcm_release_file(pcm_file);
2165 up(&pcm->open_mutex); 2165 mutex_unlock(&pcm->open_mutex);
2166 wake_up(&pcm->open_wait); 2166 wake_up(&pcm->open_wait);
2167 module_put(pcm->card->module); 2167 module_put(pcm->card->module);
2168 snd_card_file_remove(pcm->card, file); 2168 snd_card_file_remove(pcm->card, file);
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index d4d124e21924..6b7a36774298 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -28,6 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/time.h> 29#include <linux/time.h>
30#include <linux/wait.h> 30#include <linux/wait.h>
31#include <linux/mutex.h>
31#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
32#include <linux/delay.h> 33#include <linux/delay.h>
33#include <linux/wait.h> 34#include <linux/wait.h>
@@ -57,7 +58,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device);
57static int snd_rawmidi_dev_unregister(struct snd_device *device); 58static int snd_rawmidi_dev_unregister(struct snd_device *device);
58 59
59static LIST_HEAD(snd_rawmidi_devices); 60static LIST_HEAD(snd_rawmidi_devices);
60static DECLARE_MUTEX(register_mutex); 61static DEFINE_MUTEX(register_mutex);
61 62
62static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) 63static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
63{ 64{
@@ -237,9 +238,9 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
237 238
238 if (rfile) 239 if (rfile)
239 rfile->input = rfile->output = NULL; 240 rfile->input = rfile->output = NULL;
240 down(&register_mutex); 241 mutex_lock(&register_mutex);
241 rmidi = snd_rawmidi_search(card, device); 242 rmidi = snd_rawmidi_search(card, device);
242 up(&register_mutex); 243 mutex_unlock(&register_mutex);
243 if (rmidi == NULL) { 244 if (rmidi == NULL) {
244 err = -ENODEV; 245 err = -ENODEV;
245 goto __error1; 246 goto __error1;
@@ -249,7 +250,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
249 goto __error1; 250 goto __error1;
250 } 251 }
251 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) 252 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
252 down(&rmidi->open_mutex); 253 mutex_lock(&rmidi->open_mutex);
253 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) { 254 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
254 if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) { 255 if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) {
255 err = -ENXIO; 256 err = -ENXIO;
@@ -359,7 +360,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
359 soutput = NULL; 360 soutput = NULL;
360 } 361 }
361 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) 362 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
362 up(&rmidi->open_mutex); 363 mutex_unlock(&rmidi->open_mutex);
363 if (rfile) { 364 if (rfile) {
364 rfile->rmidi = rmidi; 365 rfile->rmidi = rmidi;
365 rfile->input = sinput; 366 rfile->input = sinput;
@@ -374,7 +375,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
374 snd_rawmidi_runtime_free(soutput); 375 snd_rawmidi_runtime_free(soutput);
375 module_put(rmidi->card->module); 376 module_put(rmidi->card->module);
376 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) 377 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
377 up(&rmidi->open_mutex); 378 mutex_unlock(&rmidi->open_mutex);
378 __error1: 379 __error1:
379 return err; 380 return err;
380} 381}
@@ -422,7 +423,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
422 } 423 }
423 init_waitqueue_entry(&wait, current); 424 init_waitqueue_entry(&wait, current);
424 add_wait_queue(&rmidi->open_wait, &wait); 425 add_wait_queue(&rmidi->open_wait, &wait);
425 down(&rmidi->open_mutex); 426 mutex_lock(&rmidi->open_mutex);
426 while (1) { 427 while (1) {
427 subdevice = -1; 428 subdevice = -1;
428 down_read(&card->controls_rwsem); 429 down_read(&card->controls_rwsem);
@@ -446,9 +447,9 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
446 } else 447 } else
447 break; 448 break;
448 set_current_state(TASK_INTERRUPTIBLE); 449 set_current_state(TASK_INTERRUPTIBLE);
449 up(&rmidi->open_mutex); 450 mutex_unlock(&rmidi->open_mutex);
450 schedule(); 451 schedule();
451 down(&rmidi->open_mutex); 452 mutex_lock(&rmidi->open_mutex);
452 if (signal_pending(current)) { 453 if (signal_pending(current)) {
453 err = -ERESTARTSYS; 454 err = -ERESTARTSYS;
454 break; 455 break;
@@ -467,7 +468,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
467 snd_card_file_remove(card, file); 468 snd_card_file_remove(card, file);
468 kfree(rawmidi_file); 469 kfree(rawmidi_file);
469 } 470 }
470 up(&rmidi->open_mutex); 471 mutex_unlock(&rmidi->open_mutex);
471 return err; 472 return err;
472} 473}
473 474
@@ -480,7 +481,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile)
480 snd_assert(rfile != NULL, return -ENXIO); 481 snd_assert(rfile != NULL, return -ENXIO);
481 snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); 482 snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO);
482 rmidi = rfile->rmidi; 483 rmidi = rfile->rmidi;
483 down(&rmidi->open_mutex); 484 mutex_lock(&rmidi->open_mutex);
484 if (rfile->input != NULL) { 485 if (rfile->input != NULL) {
485 substream = rfile->input; 486 substream = rfile->input;
486 rfile->input = NULL; 487 rfile->input = NULL;
@@ -514,7 +515,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile)
514 } 515 }
515 rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; 516 rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--;
516 } 517 }
517 up(&rmidi->open_mutex); 518 mutex_unlock(&rmidi->open_mutex);
518 module_put(rmidi->card->module); 519 module_put(rmidi->card->module);
519 return 0; 520 return 0;
520} 521}
@@ -576,9 +577,9 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
576 struct snd_rawmidi_substream *substream; 577 struct snd_rawmidi_substream *substream;
577 struct list_head *list; 578 struct list_head *list;
578 579
579 down(&register_mutex); 580 mutex_lock(&register_mutex);
580 rmidi = snd_rawmidi_search(card, info->device); 581 rmidi = snd_rawmidi_search(card, info->device);
581 up(&register_mutex); 582 mutex_unlock(&register_mutex);
582 if (!rmidi) 583 if (!rmidi)
583 return -ENXIO; 584 return -ENXIO;
584 if (info->stream < 0 || info->stream > 1) 585 if (info->stream < 0 || info->stream > 1)
@@ -818,7 +819,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card,
818 819
819 if (get_user(device, (int __user *)argp)) 820 if (get_user(device, (int __user *)argp))
820 return -EFAULT; 821 return -EFAULT;
821 down(&register_mutex); 822 mutex_lock(&register_mutex);
822 device = device < 0 ? 0 : device + 1; 823 device = device < 0 ? 0 : device + 1;
823 while (device < SNDRV_RAWMIDI_DEVICES) { 824 while (device < SNDRV_RAWMIDI_DEVICES) {
824 if (snd_rawmidi_search(card, device)) 825 if (snd_rawmidi_search(card, device))
@@ -827,7 +828,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card,
827 } 828 }
828 if (device == SNDRV_RAWMIDI_DEVICES) 829 if (device == SNDRV_RAWMIDI_DEVICES)
829 device = -1; 830 device = -1;
830 up(&register_mutex); 831 mutex_unlock(&register_mutex);
831 if (put_user(device, (int __user *)argp)) 832 if (put_user(device, (int __user *)argp))
832 return -EFAULT; 833 return -EFAULT;
833 return 0; 834 return 0;
@@ -1314,7 +1315,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
1314 1315
1315 rmidi = entry->private_data; 1316 rmidi = entry->private_data;
1316 snd_iprintf(buffer, "%s\n\n", rmidi->name); 1317 snd_iprintf(buffer, "%s\n\n", rmidi->name);
1317 down(&rmidi->open_mutex); 1318 mutex_lock(&rmidi->open_mutex);
1318 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { 1319 if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
1319 list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { 1320 list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) {
1320 substream = list_entry(list, struct snd_rawmidi_substream, list); 1321 substream = list_entry(list, struct snd_rawmidi_substream, list);
@@ -1355,7 +1356,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
1355 } 1356 }
1356 } 1357 }
1357 } 1358 }
1358 up(&rmidi->open_mutex); 1359 mutex_unlock(&rmidi->open_mutex);
1359} 1360}
1360 1361
1361/* 1362/*
@@ -1436,7 +1437,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
1436 } 1437 }
1437 rmidi->card = card; 1438 rmidi->card = card;
1438 rmidi->device = device; 1439 rmidi->device = device;
1439 init_MUTEX(&rmidi->open_mutex); 1440 mutex_init(&rmidi->open_mutex);
1440 init_waitqueue_head(&rmidi->open_wait); 1441 init_waitqueue_head(&rmidi->open_wait);
1441 if (id != NULL) 1442 if (id != NULL)
1442 strlcpy(rmidi->id, id, sizeof(rmidi->id)); 1443 strlcpy(rmidi->id, id, sizeof(rmidi->id));
@@ -1507,9 +1508,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1507 1508
1508 if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) 1509 if (rmidi->device >= SNDRV_RAWMIDI_DEVICES)
1509 return -ENOMEM; 1510 return -ENOMEM;
1510 down(&register_mutex); 1511 mutex_lock(&register_mutex);
1511 if (snd_rawmidi_search(rmidi->card, rmidi->device)) { 1512 if (snd_rawmidi_search(rmidi->card, rmidi->device)) {
1512 up(&register_mutex); 1513 mutex_unlock(&register_mutex);
1513 return -EBUSY; 1514 return -EBUSY;
1514 } 1515 }
1515 list_add_tail(&rmidi->list, &snd_rawmidi_devices); 1516 list_add_tail(&rmidi->list, &snd_rawmidi_devices);
@@ -1519,14 +1520,14 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1519 &snd_rawmidi_f_ops, rmidi, name)) < 0) { 1520 &snd_rawmidi_f_ops, rmidi, name)) < 0) {
1520 snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); 1521 snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
1521 list_del(&rmidi->list); 1522 list_del(&rmidi->list);
1522 up(&register_mutex); 1523 mutex_unlock(&register_mutex);
1523 return err; 1524 return err;
1524 } 1525 }
1525 if (rmidi->ops && rmidi->ops->dev_register && 1526 if (rmidi->ops && rmidi->ops->dev_register &&
1526 (err = rmidi->ops->dev_register(rmidi)) < 0) { 1527 (err = rmidi->ops->dev_register(rmidi)) < 0) {
1527 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); 1528 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
1528 list_del(&rmidi->list); 1529 list_del(&rmidi->list);
1529 up(&register_mutex); 1530 mutex_unlock(&register_mutex);
1530 return err; 1531 return err;
1531 } 1532 }
1532#ifdef CONFIG_SND_OSSEMUL 1533#ifdef CONFIG_SND_OSSEMUL
@@ -1553,7 +1554,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1553 } 1554 }
1554 } 1555 }
1555#endif /* CONFIG_SND_OSSEMUL */ 1556#endif /* CONFIG_SND_OSSEMUL */
1556 up(&register_mutex); 1557 mutex_unlock(&register_mutex);
1557 sprintf(name, "midi%d", rmidi->device); 1558 sprintf(name, "midi%d", rmidi->device);
1558 entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); 1559 entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root);
1559 if (entry) { 1560 if (entry) {
@@ -1583,9 +1584,9 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
1583{ 1584{
1584 struct snd_rawmidi *rmidi = device->device_data; 1585 struct snd_rawmidi *rmidi = device->device_data;
1585 1586
1586 down(&register_mutex); 1587 mutex_lock(&register_mutex);
1587 list_del_init(&rmidi->list); 1588 list_del_init(&rmidi->list);
1588 up(&register_mutex); 1589 mutex_unlock(&register_mutex);
1589 return 0; 1590 return 0;
1590} 1591}
1591 1592
@@ -1594,7 +1595,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device)
1594 struct snd_rawmidi *rmidi = device->device_data; 1595 struct snd_rawmidi *rmidi = device->device_data;
1595 1596
1596 snd_assert(rmidi != NULL, return -ENXIO); 1597 snd_assert(rmidi != NULL, return -ENXIO);
1597 down(&register_mutex); 1598 mutex_lock(&register_mutex);
1598 list_del(&rmidi->list); 1599 list_del(&rmidi->list);
1599 if (rmidi->proc_entry) { 1600 if (rmidi->proc_entry) {
1600 snd_info_unregister(rmidi->proc_entry); 1601 snd_info_unregister(rmidi->proc_entry);
@@ -1616,7 +1617,7 @@ static int snd_rawmidi_dev_unregister(struct snd_device *device)
1616 if (rmidi->ops && rmidi->ops->dev_unregister) 1617 if (rmidi->ops && rmidi->ops->dev_unregister)
1617 rmidi->ops->dev_unregister(rmidi); 1618 rmidi->ops->dev_unregister(rmidi);
1618 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); 1619 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
1619 up(&register_mutex); 1620 mutex_unlock(&register_mutex);
1620#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) 1621#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
1621 if (rmidi->seq_dev) { 1622 if (rmidi->seq_dev) {
1622 snd_device_free(rmidi->card, rmidi->seq_dev); 1623 snd_device_free(rmidi->card, rmidi->seq_dev);
diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
index c98f0ba13810..b9919785180b 100644
--- a/sound/core/seq/oss/seq_oss.c
+++ b/sound/core/seq/oss/seq_oss.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/mutex.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/minors.h> 29#include <sound/minors.h>
29#include <sound/initval.h> 30#include <sound/initval.h>
@@ -124,7 +125,7 @@ module_exit(alsa_seq_oss_exit)
124 * ALSA minor device interface 125 * ALSA minor device interface
125 */ 126 */
126 127
127static DECLARE_MUTEX(register_mutex); 128static DEFINE_MUTEX(register_mutex);
128 129
129static int 130static int
130odev_open(struct inode *inode, struct file *file) 131odev_open(struct inode *inode, struct file *file)
@@ -136,9 +137,9 @@ odev_open(struct inode *inode, struct file *file)
136 else 137 else
137 level = SNDRV_SEQ_OSS_MODE_SYNTH; 138 level = SNDRV_SEQ_OSS_MODE_SYNTH;
138 139
139 down(&register_mutex); 140 mutex_lock(&register_mutex);
140 rc = snd_seq_oss_open(file, level); 141 rc = snd_seq_oss_open(file, level);
141 up(&register_mutex); 142 mutex_unlock(&register_mutex);
142 143
143 return rc; 144 return rc;
144} 145}
@@ -153,9 +154,9 @@ odev_release(struct inode *inode, struct file *file)
153 154
154 snd_seq_oss_drain_write(dp); 155 snd_seq_oss_drain_write(dp);
155 156
156 down(&register_mutex); 157 mutex_lock(&register_mutex);
157 snd_seq_oss_release(dp); 158 snd_seq_oss_release(dp);
158 up(&register_mutex); 159 mutex_unlock(&register_mutex);
159 160
160 return 0; 161 return 0;
161} 162}
@@ -224,13 +225,13 @@ register_device(void)
224{ 225{
225 int rc; 226 int rc;
226 227
227 down(&register_mutex); 228 mutex_lock(&register_mutex);
228 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, 229 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
229 NULL, 0, 230 NULL, 0,
230 &seq_oss_f_ops, NULL, 231 &seq_oss_f_ops, NULL,
231 SNDRV_SEQ_OSS_DEVNAME)) < 0) { 232 SNDRV_SEQ_OSS_DEVNAME)) < 0) {
232 snd_printk(KERN_ERR "can't register device seq\n"); 233 snd_printk(KERN_ERR "can't register device seq\n");
233 up(&register_mutex); 234 mutex_unlock(&register_mutex);
234 return rc; 235 return rc;
235 } 236 }
236 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, 237 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
@@ -239,24 +240,24 @@ register_device(void)
239 SNDRV_SEQ_OSS_DEVNAME)) < 0) { 240 SNDRV_SEQ_OSS_DEVNAME)) < 0) {
240 snd_printk(KERN_ERR "can't register device music\n"); 241 snd_printk(KERN_ERR "can't register device music\n");
241 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); 242 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
242 up(&register_mutex); 243 mutex_unlock(&register_mutex);
243 return rc; 244 return rc;
244 } 245 }
245 debug_printk(("device registered\n")); 246 debug_printk(("device registered\n"));
246 up(&register_mutex); 247 mutex_unlock(&register_mutex);
247 return 0; 248 return 0;
248} 249}
249 250
250static void 251static void
251unregister_device(void) 252unregister_device(void)
252{ 253{
253 down(&register_mutex); 254 mutex_lock(&register_mutex);
254 debug_printk(("device unregistered\n")); 255 debug_printk(("device unregistered\n"));
255 if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0) 256 if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0)
256 snd_printk(KERN_ERR "error unregister device music\n"); 257 snd_printk(KERN_ERR "error unregister device music\n");
257 if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0) 258 if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0)
258 snd_printk(KERN_ERR "error unregister device seq\n"); 259 snd_printk(KERN_ERR "error unregister device seq\n");
259 up(&register_mutex); 260 mutex_unlock(&register_mutex);
260} 261}
261 262
262/* 263/*
@@ -270,12 +271,12 @@ static struct snd_info_entry *info_entry;
270static void 271static void
271info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) 272info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf)
272{ 273{
273 down(&register_mutex); 274 mutex_lock(&register_mutex);
274 snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR); 275 snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR);
275 snd_seq_oss_system_info_read(buf); 276 snd_seq_oss_system_info_read(buf);
276 snd_seq_oss_synth_info_read(buf); 277 snd_seq_oss_synth_info_read(buf);
277 snd_seq_oss_midi_info_read(buf); 278 snd_seq_oss_midi_info_read(buf);
278 up(&register_mutex); 279 mutex_unlock(&register_mutex);
279} 280}
280 281
281 282
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index fd2032eae214..aae6420f5948 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -67,7 +67,7 @@
67#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) 67#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT)
68 68
69static DEFINE_SPINLOCK(clients_lock); 69static DEFINE_SPINLOCK(clients_lock);
70static DECLARE_MUTEX(register_mutex); 70static DEFINE_MUTEX(register_mutex);
71 71
72/* 72/*
73 * client table 73 * client table
@@ -237,7 +237,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
237 client->type = NO_CLIENT; 237 client->type = NO_CLIENT;
238 snd_use_lock_init(&client->use_lock); 238 snd_use_lock_init(&client->use_lock);
239 rwlock_init(&client->ports_lock); 239 rwlock_init(&client->ports_lock);
240 init_MUTEX(&client->ports_mutex); 240 mutex_init(&client->ports_mutex);
241 INIT_LIST_HEAD(&client->ports_list_head); 241 INIT_LIST_HEAD(&client->ports_list_head);
242 242
243 /* find free slot in the client table */ 243 /* find free slot in the client table */
@@ -290,7 +290,7 @@ static int seq_free_client1(struct snd_seq_client *client)
290 290
291static void seq_free_client(struct snd_seq_client * client) 291static void seq_free_client(struct snd_seq_client * client)
292{ 292{
293 down(&register_mutex); 293 mutex_lock(&register_mutex);
294 switch (client->type) { 294 switch (client->type) {
295 case NO_CLIENT: 295 case NO_CLIENT:
296 snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n", 296 snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n",
@@ -306,7 +306,7 @@ static void seq_free_client(struct snd_seq_client * client)
306 snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n", 306 snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n",
307 client->number, client->type); 307 client->number, client->type);
308 } 308 }
309 up(&register_mutex); 309 mutex_unlock(&register_mutex);
310 310
311 snd_seq_system_client_ev_client_exit(client->number); 311 snd_seq_system_client_ev_client_exit(client->number);
312} 312}
@@ -322,11 +322,11 @@ static int snd_seq_open(struct inode *inode, struct file *file)
322 struct snd_seq_client *client; 322 struct snd_seq_client *client;
323 struct snd_seq_user_client *user; 323 struct snd_seq_user_client *user;
324 324
325 if (down_interruptible(&register_mutex)) 325 if (mutex_lock_interruptible(&register_mutex))
326 return -ERESTARTSYS; 326 return -ERESTARTSYS;
327 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); 327 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS);
328 if (client == NULL) { 328 if (client == NULL) {
329 up(&register_mutex); 329 mutex_unlock(&register_mutex);
330 return -ENOMEM; /* failure code */ 330 return -ENOMEM; /* failure code */
331 } 331 }
332 332
@@ -346,14 +346,14 @@ static int snd_seq_open(struct inode *inode, struct file *file)
346 if (user->fifo == NULL) { 346 if (user->fifo == NULL) {
347 seq_free_client1(client); 347 seq_free_client1(client);
348 kfree(client); 348 kfree(client);
349 up(&register_mutex); 349 mutex_unlock(&register_mutex);
350 return -ENOMEM; 350 return -ENOMEM;
351 } 351 }
352 } 352 }
353 353
354 usage_alloc(&client_usage, 1); 354 usage_alloc(&client_usage, 1);
355 client->type = USER_CLIENT; 355 client->type = USER_CLIENT;
356 up(&register_mutex); 356 mutex_unlock(&register_mutex);
357 357
358 c = client->number; 358 c = client->number;
359 file->private_data = client; 359 file->private_data = client;
@@ -1743,7 +1743,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client,
1743 if (queue == NULL) 1743 if (queue == NULL)
1744 return -EINVAL; 1744 return -EINVAL;
1745 1745
1746 if (down_interruptible(&queue->timer_mutex)) { 1746 if (mutex_lock_interruptible(&queue->timer_mutex)) {
1747 queuefree(queue); 1747 queuefree(queue);
1748 return -ERESTARTSYS; 1748 return -ERESTARTSYS;
1749 } 1749 }
@@ -1756,7 +1756,7 @@ static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client,
1756 timer.u.alsa.id = tmr->alsa_id; 1756 timer.u.alsa.id = tmr->alsa_id;
1757 timer.u.alsa.resolution = tmr->preferred_resolution; 1757 timer.u.alsa.resolution = tmr->preferred_resolution;
1758 } 1758 }
1759 up(&queue->timer_mutex); 1759 mutex_unlock(&queue->timer_mutex);
1760 queuefree(queue); 1760 queuefree(queue);
1761 1761
1762 if (copy_to_user(arg, &timer, sizeof(timer))) 1762 if (copy_to_user(arg, &timer, sizeof(timer)))
@@ -1785,7 +1785,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client,
1785 q = queueptr(timer.queue); 1785 q = queueptr(timer.queue);
1786 if (q == NULL) 1786 if (q == NULL)
1787 return -ENXIO; 1787 return -ENXIO;
1788 if (down_interruptible(&q->timer_mutex)) { 1788 if (mutex_lock_interruptible(&q->timer_mutex)) {
1789 queuefree(q); 1789 queuefree(q);
1790 return -ERESTARTSYS; 1790 return -ERESTARTSYS;
1791 } 1791 }
@@ -1797,7 +1797,7 @@ static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client,
1797 tmr->preferred_resolution = timer.u.alsa.resolution; 1797 tmr->preferred_resolution = timer.u.alsa.resolution;
1798 } 1798 }
1799 result = snd_seq_queue_timer_open(timer.queue); 1799 result = snd_seq_queue_timer_open(timer.queue);
1800 up(&q->timer_mutex); 1800 mutex_unlock(&q->timer_mutex);
1801 queuefree(q); 1801 queuefree(q);
1802 } else { 1802 } else {
1803 return -EPERM; 1803 return -EPERM;
@@ -2230,7 +2230,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2230 if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS) 2230 if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS)
2231 return -EINVAL; 2231 return -EINVAL;
2232 2232
2233 if (down_interruptible(&register_mutex)) 2233 if (mutex_lock_interruptible(&register_mutex))
2234 return -ERESTARTSYS; 2234 return -ERESTARTSYS;
2235 2235
2236 if (card) { 2236 if (card) {
@@ -2243,7 +2243,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2243 /* empty write queue as default */ 2243 /* empty write queue as default */
2244 client = seq_create_client1(client_index, 0); 2244 client = seq_create_client1(client_index, 0);
2245 if (client == NULL) { 2245 if (client == NULL) {
2246 up(&register_mutex); 2246 mutex_unlock(&register_mutex);
2247 return -EBUSY; /* failure code */ 2247 return -EBUSY; /* failure code */
2248 } 2248 }
2249 usage_alloc(&client_usage, 1); 2249 usage_alloc(&client_usage, 1);
@@ -2256,7 +2256,7 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2256 va_end(args); 2256 va_end(args);
2257 2257
2258 client->type = KERNEL_CLIENT; 2258 client->type = KERNEL_CLIENT;
2259 up(&register_mutex); 2259 mutex_unlock(&register_mutex);
2260 2260
2261 /* make others aware this new client */ 2261 /* make others aware this new client */
2262 snd_seq_system_client_ev_client_start(client->number); 2262 snd_seq_system_client_ev_client_start(client->number);
@@ -2464,7 +2464,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
2464{ 2464{
2465 struct list_head *l; 2465 struct list_head *l;
2466 2466
2467 down(&client->ports_mutex); 2467 mutex_lock(&client->ports_mutex);
2468 list_for_each(l, &client->ports_list_head) { 2468 list_for_each(l, &client->ports_list_head) {
2469 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 2469 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
2470 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", 2470 snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n",
@@ -2476,7 +2476,7 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
2476 snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: "); 2476 snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: ");
2477 snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: "); 2477 snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: ");
2478 } 2478 }
2479 up(&client->ports_mutex); 2479 mutex_unlock(&client->ports_mutex);
2480} 2480}
2481 2481
2482 2482
@@ -2550,16 +2550,16 @@ int __init snd_sequencer_device_init(void)
2550{ 2550{
2551 int err; 2551 int err;
2552 2552
2553 if (down_interruptible(&register_mutex)) 2553 if (mutex_lock_interruptible(&register_mutex))
2554 return -ERESTARTSYS; 2554 return -ERESTARTSYS;
2555 2555
2556 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, 2556 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
2557 &snd_seq_f_ops, NULL, "seq")) < 0) { 2557 &snd_seq_f_ops, NULL, "seq")) < 0) {
2558 up(&register_mutex); 2558 mutex_unlock(&register_mutex);
2559 return err; 2559 return err;
2560 } 2560 }
2561 2561
2562 up(&register_mutex); 2562 mutex_unlock(&register_mutex);
2563 2563
2564 return 0; 2564 return 0;
2565} 2565}
diff --git a/sound/core/seq/seq_clientmgr.h b/sound/core/seq/seq_clientmgr.h
index 450091ca153d..5e04e20e239f 100644
--- a/sound/core/seq/seq_clientmgr.h
+++ b/sound/core/seq/seq_clientmgr.h
@@ -58,7 +58,7 @@ struct snd_seq_client {
58 int num_ports; /* number of ports */ 58 int num_ports; /* number of ports */
59 struct list_head ports_list_head; 59 struct list_head ports_list_head;
60 rwlock_t ports_lock; 60 rwlock_t ports_lock;
61 struct semaphore ports_mutex; 61 struct mutex ports_mutex;
62 int convert32; /* convert 32->64bit */ 62 int convert32; /* convert 32->64bit */
63 63
64 /* output pool */ 64 /* output pool */
diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
index 9ece443fba55..d9a3e5a18d6a 100644
--- a/sound/core/seq/seq_device.c
+++ b/sound/core/seq/seq_device.c
@@ -45,6 +45,7 @@
45#include <sound/initval.h> 45#include <sound/initval.h>
46#include <linux/kmod.h> 46#include <linux/kmod.h>
47#include <linux/slab.h> 47#include <linux/slab.h>
48#include <linux/mutex.h>
48 49
49MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); 50MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
50MODULE_DESCRIPTION("ALSA sequencer device management"); 51MODULE_DESCRIPTION("ALSA sequencer device management");
@@ -69,7 +70,7 @@ struct ops_list {
69 struct list_head dev_list; /* list of devices */ 70 struct list_head dev_list; /* list of devices */
70 int num_devices; /* number of associated devices */ 71 int num_devices; /* number of associated devices */
71 int num_init_devices; /* number of initialized devices */ 72 int num_init_devices; /* number of initialized devices */
72 struct semaphore reg_mutex; 73 struct mutex reg_mutex;
73 74
74 struct list_head list; /* next driver */ 75 struct list_head list; /* next driver */
75}; 76};
@@ -77,7 +78,7 @@ struct ops_list {
77 78
78static LIST_HEAD(opslist); 79static LIST_HEAD(opslist);
79static int num_ops; 80static int num_ops;
80static DECLARE_MUTEX(ops_mutex); 81static DEFINE_MUTEX(ops_mutex);
81#ifdef CONFIG_PROC_FS 82#ifdef CONFIG_PROC_FS
82static struct snd_info_entry *info_entry = NULL; 83static struct snd_info_entry *info_entry = NULL;
83#endif 84#endif
@@ -108,7 +109,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry,
108{ 109{
109 struct list_head *head; 110 struct list_head *head;
110 111
111 down(&ops_mutex); 112 mutex_lock(&ops_mutex);
112 list_for_each(head, &opslist) { 113 list_for_each(head, &opslist) {
113 struct ops_list *ops = list_entry(head, struct ops_list, list); 114 struct ops_list *ops = list_entry(head, struct ops_list, list);
114 snd_iprintf(buffer, "snd-%s%s%s%s,%d\n", 115 snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
@@ -118,7 +119,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry,
118 ops->driver & DRIVER_LOCKED ? ",locked" : "", 119 ops->driver & DRIVER_LOCKED ? ",locked" : "",
119 ops->num_devices); 120 ops->num_devices);
120 } 121 }
121 up(&ops_mutex); 122 mutex_unlock(&ops_mutex);
122} 123}
123#endif 124#endif
124 125
@@ -154,20 +155,20 @@ void snd_seq_device_load_drivers(void)
154 if (! current->fs->root) 155 if (! current->fs->root)
155 return; 156 return;
156 157
157 down(&ops_mutex); 158 mutex_lock(&ops_mutex);
158 list_for_each(head, &opslist) { 159 list_for_each(head, &opslist) {
159 struct ops_list *ops = list_entry(head, struct ops_list, list); 160 struct ops_list *ops = list_entry(head, struct ops_list, list);
160 if (! (ops->driver & DRIVER_LOADED) && 161 if (! (ops->driver & DRIVER_LOADED) &&
161 ! (ops->driver & DRIVER_REQUESTED)) { 162 ! (ops->driver & DRIVER_REQUESTED)) {
162 ops->used++; 163 ops->used++;
163 up(&ops_mutex); 164 mutex_unlock(&ops_mutex);
164 ops->driver |= DRIVER_REQUESTED; 165 ops->driver |= DRIVER_REQUESTED;
165 request_module("snd-%s", ops->id); 166 request_module("snd-%s", ops->id);
166 down(&ops_mutex); 167 mutex_lock(&ops_mutex);
167 ops->used--; 168 ops->used--;
168 } 169 }
169 } 170 }
170 up(&ops_mutex); 171 mutex_unlock(&ops_mutex);
171#endif 172#endif
172} 173}
173 174
@@ -214,10 +215,10 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize,
214 dev->status = SNDRV_SEQ_DEVICE_FREE; 215 dev->status = SNDRV_SEQ_DEVICE_FREE;
215 216
216 /* add this device to the list */ 217 /* add this device to the list */
217 down(&ops->reg_mutex); 218 mutex_lock(&ops->reg_mutex);
218 list_add_tail(&dev->list, &ops->dev_list); 219 list_add_tail(&dev->list, &ops->dev_list);
219 ops->num_devices++; 220 ops->num_devices++;
220 up(&ops->reg_mutex); 221 mutex_unlock(&ops->reg_mutex);
221 222
222 unlock_driver(ops); 223 unlock_driver(ops);
223 224
@@ -246,10 +247,10 @@ static int snd_seq_device_free(struct snd_seq_device *dev)
246 return -ENXIO; 247 return -ENXIO;
247 248
248 /* remove the device from the list */ 249 /* remove the device from the list */
249 down(&ops->reg_mutex); 250 mutex_lock(&ops->reg_mutex);
250 list_del(&dev->list); 251 list_del(&dev->list);
251 ops->num_devices--; 252 ops->num_devices--;
252 up(&ops->reg_mutex); 253 mutex_unlock(&ops->reg_mutex);
253 254
254 free_device(dev, ops); 255 free_device(dev, ops);
255 if (dev->private_free) 256 if (dev->private_free)
@@ -344,7 +345,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
344 return -EBUSY; 345 return -EBUSY;
345 } 346 }
346 347
347 down(&ops->reg_mutex); 348 mutex_lock(&ops->reg_mutex);
348 /* copy driver operators */ 349 /* copy driver operators */
349 ops->ops = *entry; 350 ops->ops = *entry;
350 ops->driver |= DRIVER_LOADED; 351 ops->driver |= DRIVER_LOADED;
@@ -355,7 +356,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
355 struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); 356 struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
356 init_device(dev, ops); 357 init_device(dev, ops);
357 } 358 }
358 up(&ops->reg_mutex); 359 mutex_unlock(&ops->reg_mutex);
359 360
360 unlock_driver(ops); 361 unlock_driver(ops);
361 snd_seq_autoload_unlock(); 362 snd_seq_autoload_unlock();
@@ -378,17 +379,17 @@ static struct ops_list * create_driver(char *id)
378 379
379 /* set up driver entry */ 380 /* set up driver entry */
380 strlcpy(ops->id, id, sizeof(ops->id)); 381 strlcpy(ops->id, id, sizeof(ops->id));
381 init_MUTEX(&ops->reg_mutex); 382 mutex_init(&ops->reg_mutex);
382 ops->driver = DRIVER_EMPTY; 383 ops->driver = DRIVER_EMPTY;
383 INIT_LIST_HEAD(&ops->dev_list); 384 INIT_LIST_HEAD(&ops->dev_list);
384 /* lock this instance */ 385 /* lock this instance */
385 ops->used = 1; 386 ops->used = 1;
386 387
387 /* register driver entry */ 388 /* register driver entry */
388 down(&ops_mutex); 389 mutex_lock(&ops_mutex);
389 list_add_tail(&ops->list, &opslist); 390 list_add_tail(&ops->list, &opslist);
390 num_ops++; 391 num_ops++;
391 up(&ops_mutex); 392 mutex_unlock(&ops_mutex);
392 393
393 return ops; 394 return ops;
394} 395}
@@ -414,7 +415,7 @@ int snd_seq_device_unregister_driver(char *id)
414 } 415 }
415 416
416 /* close and release all devices associated with this driver */ 417 /* close and release all devices associated with this driver */
417 down(&ops->reg_mutex); 418 mutex_lock(&ops->reg_mutex);
418 ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */ 419 ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
419 list_for_each(head, &ops->dev_list) { 420 list_for_each(head, &ops->dev_list) {
420 struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); 421 struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
@@ -425,7 +426,7 @@ int snd_seq_device_unregister_driver(char *id)
425 if (ops->num_init_devices > 0) 426 if (ops->num_init_devices > 0)
426 snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n", 427 snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n",
427 ops->num_init_devices); 428 ops->num_init_devices);
428 up(&ops->reg_mutex); 429 mutex_unlock(&ops->reg_mutex);
429 430
430 unlock_driver(ops); 431 unlock_driver(ops);
431 432
@@ -443,7 +444,7 @@ static void remove_drivers(void)
443{ 444{
444 struct list_head *head; 445 struct list_head *head;
445 446
446 down(&ops_mutex); 447 mutex_lock(&ops_mutex);
447 head = opslist.next; 448 head = opslist.next;
448 while (head != &opslist) { 449 while (head != &opslist) {
449 struct ops_list *ops = list_entry(head, struct ops_list, list); 450 struct ops_list *ops = list_entry(head, struct ops_list, list);
@@ -456,7 +457,7 @@ static void remove_drivers(void)
456 } else 457 } else
457 head = head->next; 458 head = head->next;
458 } 459 }
459 up(&ops_mutex); 460 mutex_unlock(&ops_mutex);
460} 461}
461 462
462/* 463/*
@@ -519,16 +520,16 @@ static struct ops_list * find_driver(char *id, int create_if_empty)
519{ 520{
520 struct list_head *head; 521 struct list_head *head;
521 522
522 down(&ops_mutex); 523 mutex_lock(&ops_mutex);
523 list_for_each(head, &opslist) { 524 list_for_each(head, &opslist) {
524 struct ops_list *ops = list_entry(head, struct ops_list, list); 525 struct ops_list *ops = list_entry(head, struct ops_list, list);
525 if (strcmp(ops->id, id) == 0) { 526 if (strcmp(ops->id, id) == 0) {
526 ops->used++; 527 ops->used++;
527 up(&ops_mutex); 528 mutex_unlock(&ops_mutex);
528 return ops; 529 return ops;
529 } 530 }
530 } 531 }
531 up(&ops_mutex); 532 mutex_unlock(&ops_mutex);
532 if (create_if_empty) 533 if (create_if_empty)
533 return create_driver(id); 534 return create_driver(id);
534 return NULL; 535 return NULL;
@@ -536,9 +537,9 @@ static struct ops_list * find_driver(char *id, int create_if_empty)
536 537
537static void unlock_driver(struct ops_list *ops) 538static void unlock_driver(struct ops_list *ops)
538{ 539{
539 down(&ops_mutex); 540 mutex_lock(&ops_mutex);
540 ops->used--; 541 ops->used--;
541 up(&ops_mutex); 542 mutex_unlock(&ops_mutex);
542} 543}
543 544
544 545
diff --git a/sound/core/seq/seq_instr.c b/sound/core/seq/seq_instr.c
index 487452063965..f30d171b6d96 100644
--- a/sound/core/seq/seq_instr.c
+++ b/sound/core/seq/seq_instr.c
@@ -36,7 +36,7 @@ static void snd_instr_lock_ops(struct snd_seq_kinstr_list *list)
36 if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) { 36 if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
37 spin_lock_irqsave(&list->ops_lock, list->ops_flags); 37 spin_lock_irqsave(&list->ops_lock, list->ops_flags);
38 } else { 38 } else {
39 down(&list->ops_mutex); 39 mutex_lock(&list->ops_mutex);
40 } 40 }
41} 41}
42 42
@@ -45,7 +45,7 @@ static void snd_instr_unlock_ops(struct snd_seq_kinstr_list *list)
45 if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) { 45 if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
46 spin_unlock_irqrestore(&list->ops_lock, list->ops_flags); 46 spin_unlock_irqrestore(&list->ops_lock, list->ops_flags);
47 } else { 47 } else {
48 up(&list->ops_mutex); 48 mutex_unlock(&list->ops_mutex);
49 } 49 }
50} 50}
51 51
@@ -82,7 +82,7 @@ struct snd_seq_kinstr_list *snd_seq_instr_list_new(void)
82 return NULL; 82 return NULL;
83 spin_lock_init(&list->lock); 83 spin_lock_init(&list->lock);
84 spin_lock_init(&list->ops_lock); 84 spin_lock_init(&list->ops_lock);
85 init_MUTEX(&list->ops_mutex); 85 mutex_init(&list->ops_mutex);
86 list->owner = -1; 86 list->owner = -1;
87 return list; 87 return list;
88} 88}
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
index ce0df86157de..9caa1372bece 100644
--- a/sound/core/seq/seq_midi.c
+++ b/sound/core/seq/seq_midi.c
@@ -32,7 +32,7 @@ Possible options for midisynth module:
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
35#include <asm/semaphore.h> 35#include <linux/mutex.h>
36#include <sound/core.h> 36#include <sound/core.h>
37#include <sound/rawmidi.h> 37#include <sound/rawmidi.h>
38#include <sound/seq_kernel.h> 38#include <sound/seq_kernel.h>
@@ -70,7 +70,7 @@ struct seq_midisynth_client {
70}; 70};
71 71
72static struct seq_midisynth_client *synths[SNDRV_CARDS]; 72static struct seq_midisynth_client *synths[SNDRV_CARDS];
73static DECLARE_MUTEX(register_mutex); 73static DEFINE_MUTEX(register_mutex);
74 74
75/* handle rawmidi input event (MIDI v1.0 stream) */ 75/* handle rawmidi input event (MIDI v1.0 stream) */
76static void snd_midi_input_event(struct snd_rawmidi_substream *substream) 76static void snd_midi_input_event(struct snd_rawmidi_substream *substream)
@@ -308,13 +308,13 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
308 if (ports > (256 / SNDRV_RAWMIDI_DEVICES)) 308 if (ports > (256 / SNDRV_RAWMIDI_DEVICES))
309 ports = 256 / SNDRV_RAWMIDI_DEVICES; 309 ports = 256 / SNDRV_RAWMIDI_DEVICES;
310 310
311 down(&register_mutex); 311 mutex_lock(&register_mutex);
312 client = synths[card->number]; 312 client = synths[card->number];
313 if (client == NULL) { 313 if (client == NULL) {
314 newclient = 1; 314 newclient = 1;
315 client = kzalloc(sizeof(*client), GFP_KERNEL); 315 client = kzalloc(sizeof(*client), GFP_KERNEL);
316 if (client == NULL) { 316 if (client == NULL) {
317 up(&register_mutex); 317 mutex_unlock(&register_mutex);
318 kfree(info); 318 kfree(info);
319 return -ENOMEM; 319 return -ENOMEM;
320 } 320 }
@@ -324,7 +324,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
324 (const char *)info->name : "External MIDI"); 324 (const char *)info->name : "External MIDI");
325 if (client->seq_client < 0) { 325 if (client->seq_client < 0) {
326 kfree(client); 326 kfree(client);
327 up(&register_mutex); 327 mutex_unlock(&register_mutex);
328 kfree(info); 328 kfree(info);
329 return -ENOMEM; 329 return -ENOMEM;
330 } 330 }
@@ -397,7 +397,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
397 client->num_ports++; 397 client->num_ports++;
398 if (newclient) 398 if (newclient)
399 synths[card->number] = client; 399 synths[card->number] = client;
400 up(&register_mutex); 400 mutex_unlock(&register_mutex);
401 kfree(info); 401 kfree(info);
402 kfree(port); 402 kfree(port);
403 return 0; /* success */ 403 return 0; /* success */
@@ -414,7 +414,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
414 } 414 }
415 kfree(info); 415 kfree(info);
416 kfree(port); 416 kfree(port);
417 up(&register_mutex); 417 mutex_unlock(&register_mutex);
418 return -ENOMEM; 418 return -ENOMEM;
419} 419}
420 420
@@ -427,10 +427,10 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev)
427 struct snd_card *card = dev->card; 427 struct snd_card *card = dev->card;
428 int device = dev->device, p, ports; 428 int device = dev->device, p, ports;
429 429
430 down(&register_mutex); 430 mutex_lock(&register_mutex);
431 client = synths[card->number]; 431 client = synths[card->number];
432 if (client == NULL || client->ports[device] == NULL) { 432 if (client == NULL || client->ports[device] == NULL) {
433 up(&register_mutex); 433 mutex_unlock(&register_mutex);
434 return -ENODEV; 434 return -ENODEV;
435 } 435 }
436 ports = client->ports_per_device[device]; 436 ports = client->ports_per_device[device];
@@ -446,7 +446,7 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev)
446 synths[card->number] = NULL; 446 synths[card->number] = NULL;
447 kfree(client); 447 kfree(client);
448 } 448 }
449 up(&register_mutex); 449 mutex_unlock(&register_mutex);
450 return 0; 450 return 0;
451} 451}
452 452
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 2b384fd7967f..41e078c938cd 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -159,7 +159,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
159 port_subs_info_init(&new_port->c_dest); 159 port_subs_info_init(&new_port->c_dest);
160 160
161 num = port >= 0 ? port : 0; 161 num = port >= 0 ? port : 0;
162 down(&client->ports_mutex); 162 mutex_lock(&client->ports_mutex);
163 write_lock_irqsave(&client->ports_lock, flags); 163 write_lock_irqsave(&client->ports_lock, flags);
164 list_for_each(l, &client->ports_list_head) { 164 list_for_each(l, &client->ports_list_head) {
165 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 165 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
@@ -173,7 +173,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
173 client->num_ports++; 173 client->num_ports++;
174 new_port->addr.port = num; /* store the port number in the port */ 174 new_port->addr.port = num; /* store the port number in the port */
175 write_unlock_irqrestore(&client->ports_lock, flags); 175 write_unlock_irqrestore(&client->ports_lock, flags);
176 up(&client->ports_mutex); 176 mutex_unlock(&client->ports_mutex);
177 sprintf(new_port->name, "port-%d", num); 177 sprintf(new_port->name, "port-%d", num);
178 178
179 return new_port; 179 return new_port;
@@ -292,7 +292,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
292 struct list_head *l; 292 struct list_head *l;
293 struct snd_seq_client_port *found = NULL; 293 struct snd_seq_client_port *found = NULL;
294 294
295 down(&client->ports_mutex); 295 mutex_lock(&client->ports_mutex);
296 write_lock_irqsave(&client->ports_lock, flags); 296 write_lock_irqsave(&client->ports_lock, flags);
297 list_for_each(l, &client->ports_list_head) { 297 list_for_each(l, &client->ports_list_head) {
298 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); 298 struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
@@ -305,7 +305,7 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
305 } 305 }
306 } 306 }
307 write_unlock_irqrestore(&client->ports_lock, flags); 307 write_unlock_irqrestore(&client->ports_lock, flags);
308 up(&client->ports_mutex); 308 mutex_unlock(&client->ports_mutex);
309 if (found) 309 if (found)
310 return port_delete(client, found); 310 return port_delete(client, found);
311 else 311 else
@@ -321,7 +321,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
321 /* move the port list to deleted_list, and 321 /* move the port list to deleted_list, and
322 * clear the port list in the client data. 322 * clear the port list in the client data.
323 */ 323 */
324 down(&client->ports_mutex); 324 mutex_lock(&client->ports_mutex);
325 write_lock_irqsave(&client->ports_lock, flags); 325 write_lock_irqsave(&client->ports_lock, flags);
326 if (! list_empty(&client->ports_list_head)) { 326 if (! list_empty(&client->ports_list_head)) {
327 __list_add(&deleted_list, 327 __list_add(&deleted_list,
@@ -341,7 +341,7 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
341 snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port); 341 snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
342 port_delete(client, port); 342 port_delete(client, port);
343 } 343 }
344 up(&client->ports_mutex); 344 mutex_unlock(&client->ports_mutex);
345 return 0; 345 return 0;
346} 346}
347 347
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index 9cf20f045542..9b87bb0c7f33 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -119,7 +119,7 @@ static struct snd_seq_queue *queue_new(int owner, int locked)
119 119
120 spin_lock_init(&q->owner_lock); 120 spin_lock_init(&q->owner_lock);
121 spin_lock_init(&q->check_lock); 121 spin_lock_init(&q->check_lock);
122 init_MUTEX(&q->timer_mutex); 122 mutex_init(&q->timer_mutex);
123 snd_use_lock_init(&q->use_lock); 123 snd_use_lock_init(&q->use_lock);
124 q->queue = -1; 124 q->queue = -1;
125 125
@@ -516,7 +516,7 @@ int snd_seq_queue_use(int queueid, int client, int use)
516 queue = queueptr(queueid); 516 queue = queueptr(queueid);
517 if (queue == NULL) 517 if (queue == NULL)
518 return -EINVAL; 518 return -EINVAL;
519 down(&queue->timer_mutex); 519 mutex_lock(&queue->timer_mutex);
520 if (use) { 520 if (use) {
521 if (!test_and_set_bit(client, queue->clients_bitmap)) 521 if (!test_and_set_bit(client, queue->clients_bitmap))
522 queue->clients++; 522 queue->clients++;
@@ -531,7 +531,7 @@ int snd_seq_queue_use(int queueid, int client, int use)
531 } else { 531 } else {
532 snd_seq_timer_close(queue); 532 snd_seq_timer_close(queue);
533 } 533 }
534 up(&queue->timer_mutex); 534 mutex_unlock(&queue->timer_mutex);
535 queuefree(queue); 535 queuefree(queue);
536 return 0; 536 return 0;
537} 537}
diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h
index 888438599387..30c8111477f6 100644
--- a/sound/core/seq/seq_queue.h
+++ b/sound/core/seq/seq_queue.h
@@ -54,7 +54,7 @@ struct snd_seq_queue {
54 /* clients which uses this queue (bitmap) */ 54 /* clients which uses this queue (bitmap) */
55 DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS); 55 DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS);
56 unsigned int clients; /* users of this queue */ 56 unsigned int clients; /* users of this queue */
57 struct semaphore timer_mutex; 57 struct mutex timer_mutex;
58 58
59 snd_use_lock_t use_lock; 59 snd_use_lock_t use_lock;
60}; 60};
diff --git a/sound/core/sound.c b/sound/core/sound.c
index a8eda02bcf1c..df4ab94d006e 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -33,6 +33,7 @@
33#include <sound/initval.h> 33#include <sound/initval.h>
34#include <linux/kmod.h> 34#include <linux/kmod.h>
35#include <linux/devfs_fs_kernel.h> 35#include <linux/devfs_fs_kernel.h>
36#include <linux/mutex.h>
36 37
37#define SNDRV_OS_MINORS 256 38#define SNDRV_OS_MINORS 256
38 39
@@ -61,7 +62,7 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
61int snd_ecards_limit; 62int snd_ecards_limit;
62 63
63static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; 64static struct snd_minor *snd_minors[SNDRV_OS_MINORS];
64static DECLARE_MUTEX(sound_mutex); 65static DEFINE_MUTEX(sound_mutex);
65 66
66extern struct class *sound_class; 67extern struct class *sound_class;
67 68
@@ -122,13 +123,13 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
122 123
123 if (minor > ARRAY_SIZE(snd_minors)) 124 if (minor > ARRAY_SIZE(snd_minors))
124 return NULL; 125 return NULL;
125 down(&sound_mutex); 126 mutex_lock(&sound_mutex);
126 mreg = snd_minors[minor]; 127 mreg = snd_minors[minor];
127 if (mreg && mreg->type == type) 128 if (mreg && mreg->type == type)
128 private_data = mreg->private_data; 129 private_data = mreg->private_data;
129 else 130 else
130 private_data = NULL; 131 private_data = NULL;
131 up(&sound_mutex); 132 mutex_unlock(&sound_mutex);
132 return private_data; 133 return private_data;
133} 134}
134 135
@@ -256,7 +257,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
256 preg->f_ops = f_ops; 257 preg->f_ops = f_ops;
257 preg->private_data = private_data; 258 preg->private_data = private_data;
258 strcpy(preg->name, name); 259 strcpy(preg->name, name);
259 down(&sound_mutex); 260 mutex_lock(&sound_mutex);
260#ifdef CONFIG_SND_DYNAMIC_MINORS 261#ifdef CONFIG_SND_DYNAMIC_MINORS
261 minor = snd_find_free_minor(); 262 minor = snd_find_free_minor();
262#else 263#else
@@ -265,7 +266,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
265 minor = -EBUSY; 266 minor = -EBUSY;
266#endif 267#endif
267 if (minor < 0) { 268 if (minor < 0) {
268 up(&sound_mutex); 269 mutex_unlock(&sound_mutex);
269 kfree(preg); 270 kfree(preg);
270 return minor; 271 return minor;
271 } 272 }
@@ -276,7 +277,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
276 device = card->dev; 277 device = card->dev;
277 class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name); 278 class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);
278 279
279 up(&sound_mutex); 280 mutex_unlock(&sound_mutex);
280 return 0; 281 return 0;
281} 282}
282 283
@@ -297,7 +298,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
297 struct snd_minor *mptr; 298 struct snd_minor *mptr;
298 299
299 cardnum = card ? card->number : -1; 300 cardnum = card ? card->number : -1;
300 down(&sound_mutex); 301 mutex_lock(&sound_mutex);
301 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) 302 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor)
302 if ((mptr = snd_minors[minor]) != NULL && 303 if ((mptr = snd_minors[minor]) != NULL &&
303 mptr->type == type && 304 mptr->type == type &&
@@ -305,7 +306,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
305 mptr->device == dev) 306 mptr->device == dev)
306 break; 307 break;
307 if (minor == ARRAY_SIZE(snd_minors)) { 308 if (minor == ARRAY_SIZE(snd_minors)) {
308 up(&sound_mutex); 309 mutex_unlock(&sound_mutex);
309 return -EINVAL; 310 return -EINVAL;
310 } 311 }
311 312
@@ -315,7 +316,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
315 class_device_destroy(sound_class, MKDEV(major, minor)); 316 class_device_destroy(sound_class, MKDEV(major, minor));
316 317
317 snd_minors[minor] = NULL; 318 snd_minors[minor] = NULL;
318 up(&sound_mutex); 319 mutex_unlock(&sound_mutex);
319 kfree(mptr); 320 kfree(mptr);
320 return 0; 321 return 0;
321} 322}
@@ -354,7 +355,7 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
354 int minor; 355 int minor;
355 struct snd_minor *mptr; 356 struct snd_minor *mptr;
356 357
357 down(&sound_mutex); 358 mutex_lock(&sound_mutex);
358 for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) { 359 for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) {
359 if (!(mptr = snd_minors[minor])) 360 if (!(mptr = snd_minors[minor]))
360 continue; 361 continue;
@@ -371,7 +372,7 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
371 snd_iprintf(buffer, "%3i: : %s\n", minor, 372 snd_iprintf(buffer, "%3i: : %s\n", minor,
372 snd_device_type_name(mptr->type)); 373 snd_device_type_name(mptr->type));
373 } 374 }
374 up(&sound_mutex); 375 mutex_unlock(&sound_mutex);
375} 376}
376 377
377int __init snd_minor_info_init(void) 378int __init snd_minor_info_init(void)
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index d0be32b517c1..6b4a4bccd8fe 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -34,11 +34,12 @@
34#include <sound/minors.h> 34#include <sound/minors.h>
35#include <sound/info.h> 35#include <sound/info.h>
36#include <linux/sound.h> 36#include <linux/sound.h>
37#include <linux/mutex.h>
37 38
38#define SNDRV_OSS_MINORS 128 39#define SNDRV_OSS_MINORS 128
39 40
40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; 41static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
41static DECLARE_MUTEX(sound_oss_mutex); 42static DEFINE_MUTEX(sound_oss_mutex);
42 43
43void *snd_lookup_oss_minor_data(unsigned int minor, int type) 44void *snd_lookup_oss_minor_data(unsigned int minor, int type)
44{ 45{
@@ -47,13 +48,13 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
47 48
48 if (minor > ARRAY_SIZE(snd_oss_minors)) 49 if (minor > ARRAY_SIZE(snd_oss_minors))
49 return NULL; 50 return NULL;
50 down(&sound_oss_mutex); 51 mutex_lock(&sound_oss_mutex);
51 mreg = snd_oss_minors[minor]; 52 mreg = snd_oss_minors[minor];
52 if (mreg && mreg->type == type) 53 if (mreg && mreg->type == type)
53 private_data = mreg->private_data; 54 private_data = mreg->private_data;
54 else 55 else
55 private_data = NULL; 56 private_data = NULL;
56 up(&sound_oss_mutex); 57 mutex_unlock(&sound_oss_mutex);
57 return private_data; 58 return private_data;
58} 59}
59 60
@@ -117,7 +118,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
117 preg->device = dev; 118 preg->device = dev;
118 preg->f_ops = f_ops; 119 preg->f_ops = f_ops;
119 preg->private_data = private_data; 120 preg->private_data = private_data;
120 down(&sound_oss_mutex); 121 mutex_lock(&sound_oss_mutex);
121 snd_oss_minors[minor] = preg; 122 snd_oss_minors[minor] = preg;
122 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); 123 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
123 switch (minor_unit) { 124 switch (minor_unit) {
@@ -143,7 +144,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
143 goto __end; 144 goto __end;
144 snd_oss_minors[track2] = preg; 145 snd_oss_minors[track2] = preg;
145 } 146 }
146 up(&sound_oss_mutex); 147 mutex_unlock(&sound_oss_mutex);
147 return 0; 148 return 0;
148 149
149 __end: 150 __end:
@@ -152,7 +153,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
152 if (register1 >= 0) 153 if (register1 >= 0)
153 unregister_sound_special(register1); 154 unregister_sound_special(register1);
154 snd_oss_minors[minor] = NULL; 155 snd_oss_minors[minor] = NULL;
155 up(&sound_oss_mutex); 156 mutex_unlock(&sound_oss_mutex);
156 kfree(preg); 157 kfree(preg);
157 return -EBUSY; 158 return -EBUSY;
158} 159}
@@ -168,10 +169,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
168 return 0; 169 return 0;
169 if (minor < 0) 170 if (minor < 0)
170 return minor; 171 return minor;
171 down(&sound_oss_mutex); 172 mutex_lock(&sound_oss_mutex);
172 mptr = snd_oss_minors[minor]; 173 mptr = snd_oss_minors[minor];
173 if (mptr == NULL) { 174 if (mptr == NULL) {
174 up(&sound_oss_mutex); 175 mutex_unlock(&sound_oss_mutex);
175 return -ENOENT; 176 return -ENOENT;
176 } 177 }
177 unregister_sound_special(minor); 178 unregister_sound_special(minor);
@@ -191,7 +192,7 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
191 snd_oss_minors[track2] = NULL; 192 snd_oss_minors[track2] = NULL;
192 } 193 }
193 snd_oss_minors[minor] = NULL; 194 snd_oss_minors[minor] = NULL;
194 up(&sound_oss_mutex); 195 mutex_unlock(&sound_oss_mutex);
195 kfree(mptr); 196 kfree(mptr);
196 return 0; 197 return 0;
197} 198}
@@ -229,7 +230,7 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
229 int minor; 230 int minor;
230 struct snd_minor *mptr; 231 struct snd_minor *mptr;
231 232
232 down(&sound_oss_mutex); 233 mutex_lock(&sound_oss_mutex);
233 for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) { 234 for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) {
234 if (!(mptr = snd_oss_minors[minor])) 235 if (!(mptr = snd_oss_minors[minor]))
235 continue; 236 continue;
@@ -241,7 +242,7 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
241 snd_iprintf(buffer, "%3i: : %s\n", minor, 242 snd_iprintf(buffer, "%3i: : %s\n", minor,
242 snd_oss_device_type_name(mptr->type)); 243 snd_oss_device_type_name(mptr->type));
243 } 244 }
244 up(&sound_oss_mutex); 245 mutex_unlock(&sound_oss_mutex);
245} 246}
246 247
247 248
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 2425b971b240..cdeeb639b675 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -25,6 +25,7 @@
25#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/mutex.h>
28#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
29#include <linux/string.h> 30#include <linux/string.h>
30#include <sound/core.h> 31#include <sound/core.h>
@@ -70,7 +71,7 @@ struct snd_timer_user {
70 struct timespec tstamp; /* trigger tstamp */ 71 struct timespec tstamp; /* trigger tstamp */
71 wait_queue_head_t qchange_sleep; 72 wait_queue_head_t qchange_sleep;
72 struct fasync_struct *fasync; 73 struct fasync_struct *fasync;
73 struct semaphore tread_sem; 74 struct mutex tread_sem;
74}; 75};
75 76
76/* list of timers */ 77/* list of timers */
@@ -82,7 +83,7 @@ static LIST_HEAD(snd_timer_slave_list);
82/* lock for slave active lists */ 83/* lock for slave active lists */
83static DEFINE_SPINLOCK(slave_active_lock); 84static DEFINE_SPINLOCK(slave_active_lock);
84 85
85static DECLARE_MUTEX(register_mutex); 86static DEFINE_MUTEX(register_mutex);
86 87
87static int snd_timer_free(struct snd_timer *timer); 88static int snd_timer_free(struct snd_timer *timer);
88static int snd_timer_dev_free(struct snd_device *device); 89static int snd_timer_dev_free(struct snd_device *device);
@@ -252,10 +253,10 @@ int snd_timer_open(struct snd_timer_instance **ti,
252 snd_printd("invalid slave class %i\n", tid->dev_sclass); 253 snd_printd("invalid slave class %i\n", tid->dev_sclass);
253 return -EINVAL; 254 return -EINVAL;
254 } 255 }
255 down(&register_mutex); 256 mutex_lock(&register_mutex);
256 timeri = snd_timer_instance_new(owner, NULL); 257 timeri = snd_timer_instance_new(owner, NULL);
257 if (!timeri) { 258 if (!timeri) {
258 up(&register_mutex); 259 mutex_unlock(&register_mutex);
259 return -ENOMEM; 260 return -ENOMEM;
260 } 261 }
261 timeri->slave_class = tid->dev_sclass; 262 timeri->slave_class = tid->dev_sclass;
@@ -263,37 +264,37 @@ int snd_timer_open(struct snd_timer_instance **ti,
263 timeri->flags |= SNDRV_TIMER_IFLG_SLAVE; 264 timeri->flags |= SNDRV_TIMER_IFLG_SLAVE;
264 list_add_tail(&timeri->open_list, &snd_timer_slave_list); 265 list_add_tail(&timeri->open_list, &snd_timer_slave_list);
265 snd_timer_check_slave(timeri); 266 snd_timer_check_slave(timeri);
266 up(&register_mutex); 267 mutex_unlock(&register_mutex);
267 *ti = timeri; 268 *ti = timeri;
268 return 0; 269 return 0;
269 } 270 }
270 271
271 /* open a master instance */ 272 /* open a master instance */
272 down(&register_mutex); 273 mutex_lock(&register_mutex);
273 timer = snd_timer_find(tid); 274 timer = snd_timer_find(tid);
274#ifdef CONFIG_KMOD 275#ifdef CONFIG_KMOD
275 if (timer == NULL) { 276 if (timer == NULL) {
276 up(&register_mutex); 277 mutex_unlock(&register_mutex);
277 snd_timer_request(tid); 278 snd_timer_request(tid);
278 down(&register_mutex); 279 mutex_lock(&register_mutex);
279 timer = snd_timer_find(tid); 280 timer = snd_timer_find(tid);
280 } 281 }
281#endif 282#endif
282 if (!timer) { 283 if (!timer) {
283 up(&register_mutex); 284 mutex_unlock(&register_mutex);
284 return -ENODEV; 285 return -ENODEV;
285 } 286 }
286 if (!list_empty(&timer->open_list_head)) { 287 if (!list_empty(&timer->open_list_head)) {
287 timeri = list_entry(timer->open_list_head.next, 288 timeri = list_entry(timer->open_list_head.next,
288 struct snd_timer_instance, open_list); 289 struct snd_timer_instance, open_list);
289 if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) { 290 if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) {
290 up(&register_mutex); 291 mutex_unlock(&register_mutex);
291 return -EBUSY; 292 return -EBUSY;
292 } 293 }
293 } 294 }
294 timeri = snd_timer_instance_new(owner, timer); 295 timeri = snd_timer_instance_new(owner, timer);
295 if (!timeri) { 296 if (!timeri) {
296 up(&register_mutex); 297 mutex_unlock(&register_mutex);
297 return -ENOMEM; 298 return -ENOMEM;
298 } 299 }
299 timeri->slave_class = tid->dev_sclass; 300 timeri->slave_class = tid->dev_sclass;
@@ -302,7 +303,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
302 timer->hw.open(timer); 303 timer->hw.open(timer);
303 list_add_tail(&timeri->open_list, &timer->open_list_head); 304 list_add_tail(&timeri->open_list, &timer->open_list_head);
304 snd_timer_check_master(timeri); 305 snd_timer_check_master(timeri);
305 up(&register_mutex); 306 mutex_unlock(&register_mutex);
306 *ti = timeri; 307 *ti = timeri;
307 return 0; 308 return 0;
308} 309}
@@ -333,9 +334,9 @@ int snd_timer_close(struct snd_timer_instance *timeri)
333 spin_lock_irq(&slave_active_lock); 334 spin_lock_irq(&slave_active_lock);
334 } 335 }
335 spin_unlock_irq(&slave_active_lock); 336 spin_unlock_irq(&slave_active_lock);
336 down(&register_mutex); 337 mutex_lock(&register_mutex);
337 list_del(&timeri->open_list); 338 list_del(&timeri->open_list);
338 up(&register_mutex); 339 mutex_unlock(&register_mutex);
339 } else { 340 } else {
340 timer = timeri->timer; 341 timer = timeri->timer;
341 /* wait, until the active callback is finished */ 342 /* wait, until the active callback is finished */
@@ -346,7 +347,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
346 spin_lock_irq(&timer->lock); 347 spin_lock_irq(&timer->lock);
347 } 348 }
348 spin_unlock_irq(&timer->lock); 349 spin_unlock_irq(&timer->lock);
349 down(&register_mutex); 350 mutex_lock(&register_mutex);
350 list_del(&timeri->open_list); 351 list_del(&timeri->open_list);
351 if (timer && list_empty(&timer->open_list_head) && 352 if (timer && list_empty(&timer->open_list_head) &&
352 timer->hw.close) 353 timer->hw.close)
@@ -362,7 +363,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
362 slave->timer = NULL; 363 slave->timer = NULL;
363 spin_unlock_irq(&slave_active_lock); 364 spin_unlock_irq(&slave_active_lock);
364 } 365 }
365 up(&register_mutex); 366 mutex_unlock(&register_mutex);
366 } 367 }
367 if (timeri->private_free) 368 if (timeri->private_free)
368 timeri->private_free(timeri); 369 timeri->private_free(timeri);
@@ -835,7 +836,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
835 !timer->hw.resolution && timer->hw.c_resolution == NULL) 836 !timer->hw.resolution && timer->hw.c_resolution == NULL)
836 return -EINVAL; 837 return -EINVAL;
837 838
838 down(&register_mutex); 839 mutex_lock(&register_mutex);
839 list_for_each(p, &snd_timer_list) { 840 list_for_each(p, &snd_timer_list) {
840 timer1 = list_entry(p, struct snd_timer, device_list); 841 timer1 = list_entry(p, struct snd_timer, device_list);
841 if (timer1->tmr_class > timer->tmr_class) 842 if (timer1->tmr_class > timer->tmr_class)
@@ -857,11 +858,11 @@ static int snd_timer_dev_register(struct snd_device *dev)
857 if (timer1->tmr_subdevice < timer->tmr_subdevice) 858 if (timer1->tmr_subdevice < timer->tmr_subdevice)
858 continue; 859 continue;
859 /* conflicts.. */ 860 /* conflicts.. */
860 up(&register_mutex); 861 mutex_unlock(&register_mutex);
861 return -EBUSY; 862 return -EBUSY;
862 } 863 }
863 list_add_tail(&timer->device_list, p); 864 list_add_tail(&timer->device_list, p);
864 up(&register_mutex); 865 mutex_unlock(&register_mutex);
865 return 0; 866 return 0;
866} 867}
867 868
@@ -871,7 +872,7 @@ static int snd_timer_unregister(struct snd_timer *timer)
871 struct snd_timer_instance *ti; 872 struct snd_timer_instance *ti;
872 873
873 snd_assert(timer != NULL, return -ENXIO); 874 snd_assert(timer != NULL, return -ENXIO);
874 down(&register_mutex); 875 mutex_lock(&register_mutex);
875 if (! list_empty(&timer->open_list_head)) { 876 if (! list_empty(&timer->open_list_head)) {
876 snd_printk(KERN_WARNING "timer 0x%lx is busy?\n", (long)timer); 877 snd_printk(KERN_WARNING "timer 0x%lx is busy?\n", (long)timer);
877 list_for_each_safe(p, n, &timer->open_list_head) { 878 list_for_each_safe(p, n, &timer->open_list_head) {
@@ -881,7 +882,7 @@ static int snd_timer_unregister(struct snd_timer *timer)
881 } 882 }
882 } 883 }
883 list_del(&timer->device_list); 884 list_del(&timer->device_list);
884 up(&register_mutex); 885 mutex_unlock(&register_mutex);
885 return snd_timer_free(timer); 886 return snd_timer_free(timer);
886} 887}
887 888
@@ -1065,7 +1066,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
1065 struct snd_timer_instance *ti; 1066 struct snd_timer_instance *ti;
1066 struct list_head *p, *q; 1067 struct list_head *p, *q;
1067 1068
1068 down(&register_mutex); 1069 mutex_lock(&register_mutex);
1069 list_for_each(p, &snd_timer_list) { 1070 list_for_each(p, &snd_timer_list) {
1070 timer = list_entry(p, struct snd_timer, device_list); 1071 timer = list_entry(p, struct snd_timer, device_list);
1071 switch (timer->tmr_class) { 1072 switch (timer->tmr_class) {
@@ -1105,7 +1106,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
1105 } 1106 }
1106 spin_unlock_irqrestore(&timer->lock, flags); 1107 spin_unlock_irqrestore(&timer->lock, flags);
1107 } 1108 }
1108 up(&register_mutex); 1109 mutex_unlock(&register_mutex);
1109} 1110}
1110 1111
1111static struct snd_info_entry *snd_timer_proc_entry = NULL; 1112static struct snd_info_entry *snd_timer_proc_entry = NULL;
@@ -1269,7 +1270,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file)
1269 return -ENOMEM; 1270 return -ENOMEM;
1270 spin_lock_init(&tu->qlock); 1271 spin_lock_init(&tu->qlock);
1271 init_waitqueue_head(&tu->qchange_sleep); 1272 init_waitqueue_head(&tu->qchange_sleep);
1272 init_MUTEX(&tu->tread_sem); 1273 mutex_init(&tu->tread_sem);
1273 tu->ticks = 1; 1274 tu->ticks = 1;
1274 tu->queue_size = 128; 1275 tu->queue_size = 128;
1275 tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read), 1276 tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read),
@@ -1325,7 +1326,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
1325 1326
1326 if (copy_from_user(&id, _tid, sizeof(id))) 1327 if (copy_from_user(&id, _tid, sizeof(id)))
1327 return -EFAULT; 1328 return -EFAULT;
1328 down(&register_mutex); 1329 mutex_lock(&register_mutex);
1329 if (id.dev_class < 0) { /* first item */ 1330 if (id.dev_class < 0) { /* first item */
1330 if (list_empty(&snd_timer_list)) 1331 if (list_empty(&snd_timer_list))
1331 snd_timer_user_zero_id(&id); 1332 snd_timer_user_zero_id(&id);
@@ -1407,7 +1408,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
1407 snd_timer_user_zero_id(&id); 1408 snd_timer_user_zero_id(&id);
1408 } 1409 }
1409 } 1410 }
1410 up(&register_mutex); 1411 mutex_unlock(&register_mutex);
1411 if (copy_to_user(_tid, &id, sizeof(*_tid))) 1412 if (copy_to_user(_tid, &id, sizeof(*_tid)))
1412 return -EFAULT; 1413 return -EFAULT;
1413 return 0; 1414 return 0;
@@ -1432,7 +1433,7 @@ static int snd_timer_user_ginfo(struct file *file,
1432 tid = ginfo->tid; 1433 tid = ginfo->tid;
1433 memset(ginfo, 0, sizeof(*ginfo)); 1434 memset(ginfo, 0, sizeof(*ginfo));
1434 ginfo->tid = tid; 1435 ginfo->tid = tid;
1435 down(&register_mutex); 1436 mutex_lock(&register_mutex);
1436 t = snd_timer_find(&tid); 1437 t = snd_timer_find(&tid);
1437 if (t != NULL) { 1438 if (t != NULL) {
1438 ginfo->card = t->card ? t->card->number : -1; 1439 ginfo->card = t->card ? t->card->number : -1;
@@ -1451,7 +1452,7 @@ static int snd_timer_user_ginfo(struct file *file,
1451 } else { 1452 } else {
1452 err = -ENODEV; 1453 err = -ENODEV;
1453 } 1454 }
1454 up(&register_mutex); 1455 mutex_unlock(&register_mutex);
1455 if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo))) 1456 if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
1456 err = -EFAULT; 1457 err = -EFAULT;
1457 kfree(ginfo); 1458 kfree(ginfo);
@@ -1467,7 +1468,7 @@ static int snd_timer_user_gparams(struct file *file,
1467 1468
1468 if (copy_from_user(&gparams, _gparams, sizeof(gparams))) 1469 if (copy_from_user(&gparams, _gparams, sizeof(gparams)))
1469 return -EFAULT; 1470 return -EFAULT;
1470 down(&register_mutex); 1471 mutex_lock(&register_mutex);
1471 t = snd_timer_find(&gparams.tid); 1472 t = snd_timer_find(&gparams.tid);
1472 if (!t) { 1473 if (!t) {
1473 err = -ENODEV; 1474 err = -ENODEV;
@@ -1483,7 +1484,7 @@ static int snd_timer_user_gparams(struct file *file,
1483 } 1484 }
1484 err = t->hw.set_period(t, gparams.period_num, gparams.period_den); 1485 err = t->hw.set_period(t, gparams.period_num, gparams.period_den);
1485_error: 1486_error:
1486 up(&register_mutex); 1487 mutex_unlock(&register_mutex);
1487 return err; 1488 return err;
1488} 1489}
1489 1490
@@ -1500,7 +1501,7 @@ static int snd_timer_user_gstatus(struct file *file,
1500 tid = gstatus.tid; 1501 tid = gstatus.tid;
1501 memset(&gstatus, 0, sizeof(gstatus)); 1502 memset(&gstatus, 0, sizeof(gstatus));
1502 gstatus.tid = tid; 1503 gstatus.tid = tid;
1503 down(&register_mutex); 1504 mutex_lock(&register_mutex);
1504 t = snd_timer_find(&tid); 1505 t = snd_timer_find(&tid);
1505 if (t != NULL) { 1506 if (t != NULL) {
1506 if (t->hw.c_resolution) 1507 if (t->hw.c_resolution)
@@ -1517,7 +1518,7 @@ static int snd_timer_user_gstatus(struct file *file,
1517 } else { 1518 } else {
1518 err = -ENODEV; 1519 err = -ENODEV;
1519 } 1520 }
1520 up(&register_mutex); 1521 mutex_unlock(&register_mutex);
1521 if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus))) 1522 if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus)))
1522 err = -EFAULT; 1523 err = -EFAULT;
1523 return err; 1524 return err;
@@ -1532,7 +1533,7 @@ static int snd_timer_user_tselect(struct file *file,
1532 int err = 0; 1533 int err = 0;
1533 1534
1534 tu = file->private_data; 1535 tu = file->private_data;
1535 down(&tu->tread_sem); 1536 mutex_lock(&tu->tread_sem);
1536 if (tu->timeri) { 1537 if (tu->timeri) {
1537 snd_timer_close(tu->timeri); 1538 snd_timer_close(tu->timeri);
1538 tu->timeri = NULL; 1539 tu->timeri = NULL;
@@ -1576,7 +1577,7 @@ static int snd_timer_user_tselect(struct file *file,
1576 } 1577 }
1577 1578
1578 __err: 1579 __err:
1579 up(&tu->tread_sem); 1580 mutex_unlock(&tu->tread_sem);
1580 return err; 1581 return err;
1581} 1582}
1582 1583
@@ -1797,17 +1798,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,
1797 { 1798 {
1798 int xarg; 1799 int xarg;
1799 1800
1800 down(&tu->tread_sem); 1801 mutex_lock(&tu->tread_sem);
1801 if (tu->timeri) { /* too late */ 1802 if (tu->timeri) { /* too late */
1802 up(&tu->tread_sem); 1803 mutex_unlock(&tu->tread_sem);
1803 return -EBUSY; 1804 return -EBUSY;
1804 } 1805 }
1805 if (get_user(xarg, p)) { 1806 if (get_user(xarg, p)) {
1806 up(&tu->tread_sem); 1807 mutex_unlock(&tu->tread_sem);
1807 return -EFAULT; 1808 return -EFAULT;
1808 } 1809 }
1809 tu->tread = xarg ? 1 : 0; 1810 tu->tread = xarg ? 1 : 0;
1810 up(&tu->tread_sem); 1811 mutex_unlock(&tu->tread_sem);
1811 return 0; 1812 return 0;
1812 } 1813 }
1813 case SNDRV_TIMER_IOCTL_GINFO: 1814 case SNDRV_TIMER_IOCTL_GINFO: