aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/hwdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/hwdep.c')
-rw-r--r--sound/core/hwdep.c43
1 files changed, 22 insertions, 21 deletions
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;