Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Ingo Molnar and committed by
Jaroslav Kysela
1a60d4c5 f0283f45

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