diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-01-16 16:29:08 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 10:24:50 +0100 |
commit | 1a60d4c5a0c4028559585a74e48593b16e1ca9b2 (patch) | |
tree | f03f8dfcd554f8ebbb295522dc46dfe4d110a484 | |
parent | f0283f45a04d5cf31512e5e390a38504d97e7a97 (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>
30 files changed, 293 insertions, 282 deletions
diff --git a/include/sound/core.h b/include/sound/core.h index 3093e3ddcf3..144bdc2f217 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -23,7 +23,7 @@ */ #include <linux/sched.h> /* wake_up() */ -#include <asm/semaphore.h> /* struct semaphore */ +#include <linux/mutex.h> /* struct mutex */ #include <linux/rwsem.h> /* struct rw_semaphore */ #include <linux/workqueue.h> /* struct workqueue_struct */ #include <linux/pm.h> /* pm_message_t */ @@ -137,7 +137,7 @@ struct snd_card { #ifdef CONFIG_PM unsigned int power_state; /* power state */ - struct semaphore power_lock; /* power lock */ + struct mutex power_lock; /* power lock */ wait_queue_head_t power_sleep; #endif @@ -150,12 +150,12 @@ struct snd_card { #ifdef CONFIG_PM static inline void snd_power_lock(struct snd_card *card) { - down(&card->power_lock); + mutex_lock(&card->power_lock); } static inline void snd_power_unlock(struct snd_card *card) { - up(&card->power_lock); + mutex_unlock(&card->power_lock); } static inline unsigned int snd_power_get_state(struct snd_card *card) diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index c679e5b3111..94c387b5d72 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -60,7 +60,7 @@ struct snd_hwdep { void *private_data; void (*private_free) (struct snd_hwdep *hwdep); - struct semaphore open_mutex; + struct mutex open_mutex; int used; unsigned int dsp_loaded; unsigned int exclusive: 1; diff --git a/include/sound/info.h b/include/sound/info.h index 8ea5c7497c0..f23d8381c21 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -84,7 +84,7 @@ struct snd_info_entry { void *private_data; void (*private_free)(struct snd_info_entry *entry); struct proc_dir_entry *p; - struct semaphore access; + struct mutex access; }; #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) diff --git a/include/sound/mixer_oss.h b/include/sound/mixer_oss.h index ca5b4822b62..197b9e3d612 100644 --- a/include/sound/mixer_oss.h +++ b/include/sound/mixer_oss.h @@ -61,7 +61,7 @@ struct snd_mixer_oss { unsigned int active_index); void *private_data_recsrc; void (*private_free_recsrc)(struct snd_mixer_oss *mixer); - struct semaphore reg_mutex; + struct mutex reg_mutex; struct snd_info_entry *proc_entry; int oss_dev_alloc; /* --- */ diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 314268a1104..15b885660bf 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -420,7 +420,7 @@ struct snd_pcm { char id[64]; char name[80]; struct snd_pcm_str streams[2]; - struct semaphore open_mutex; + struct mutex open_mutex; wait_queue_head_t open_wait; void *private_data; void (*private_free) (struct snd_pcm *pcm); diff --git a/include/sound/pcm_oss.h b/include/sound/pcm_oss.h index d6ec886637d..bff0778e196 100644 --- a/include/sound/pcm_oss.h +++ b/include/sound/pcm_oss.h @@ -75,7 +75,7 @@ struct snd_pcm_oss_substream { struct snd_pcm_oss_stream { struct snd_pcm_oss_setup *setup_list; /* setup list */ - struct semaphore setup_mutex; + struct mutex setup_mutex; struct snd_info_entry *proc_entry; }; diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h index d19bddfbf99..584e73dd479 100644 --- a/include/sound/rawmidi.h +++ b/include/sound/rawmidi.h @@ -26,7 +26,7 @@ #include <linux/interrupt.h> #include <linux/spinlock.h> #include <linux/wait.h> -#include <asm/semaphore.h> +#include <linux/mutex.h> #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) #include "seq_device.h" @@ -130,7 +130,7 @@ struct snd_rawmidi { void *private_data; void (*private_free) (struct snd_rawmidi *rmidi); - struct semaphore open_mutex; + struct mutex open_mutex; wait_queue_head_t open_wait; struct snd_info_entry *dev; diff --git a/include/sound/seq_instr.h b/include/sound/seq_instr.h index db764f09efb..f2db03bfd74 100644 --- a/include/sound/seq_instr.h +++ b/include/sound/seq_instr.h @@ -64,7 +64,7 @@ struct snd_seq_kinstr_list { spinlock_t lock; spinlock_t ops_lock; - struct semaphore ops_mutex; + struct mutex ops_mutex; unsigned long ops_flags; }; diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 618c43be0bc..2524e66eccd 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -25,6 +25,7 @@ #include <linux/smp_lock.h> #include <linux/slab.h> #include <linux/time.h> +#include <linux/mutex.h> #include <sound/core.h> #include <sound/control.h> #include <sound/minors.h> @@ -36,7 +37,7 @@ MODULE_DESCRIPTION("Hardware dependent layer"); MODULE_LICENSE("GPL"); static LIST_HEAD(snd_hwdep_devices); -static DECLARE_MUTEX(register_mutex); +static DEFINE_MUTEX(register_mutex); static int snd_hwdep_free(struct snd_hwdep *hwdep); static int snd_hwdep_dev_free(struct snd_device *device); @@ -111,7 +112,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) init_waitqueue_entry(&wait, current); add_wait_queue(&hw->open_wait, &wait); - down(&hw->open_mutex); + mutex_lock(&hw->open_mutex); while (1) { if (hw->exclusive && hw->used > 0) { err = -EBUSY; @@ -128,9 +129,9 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) } else break; set_current_state(TASK_INTERRUPTIBLE); - up(&hw->open_mutex); + mutex_unlock(&hw->open_mutex); schedule(); - down(&hw->open_mutex); + mutex_lock(&hw->open_mutex); if (signal_pending(current)) { err = -ERESTARTSYS; break; @@ -147,7 +148,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) hw->ops.release(hw, file); } } - up(&hw->open_mutex); + mutex_unlock(&hw->open_mutex); if (err < 0) module_put(hw->card->module); return err; @@ -157,7 +158,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) { int err = -ENXIO; struct snd_hwdep *hw = file->private_data; - down(&hw->open_mutex); + mutex_lock(&hw->open_mutex); if (hw->ops.release) { err = hw->ops.release(hw, file); wake_up(&hw->open_wait); @@ -165,7 +166,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) if (hw->used > 0) hw->used--; snd_card_file_remove(hw->card, file); - up(&hw->open_mutex); + mutex_unlock(&hw->open_mutex); module_put(hw->card->module); return err; } @@ -272,7 +273,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)arg)) return -EFAULT; - down(®ister_mutex); + mutex_lock(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_MINOR_HWDEPS) { if (snd_hwdep_search(card, device)) @@ -281,7 +282,7 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, } if (device >= SNDRV_MINOR_HWDEPS) device = -1; - up(®ister_mutex); + mutex_unlock(®ister_mutex); if (put_user(device, (int __user *)arg)) return -EFAULT; return 0; @@ -294,13 +295,13 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, if (get_user(device, &info->device)) return -EFAULT; - down(®ister_mutex); + mutex_lock(®ister_mutex); hwdep = snd_hwdep_search(card, device); if (hwdep) err = snd_hwdep_info(hwdep, info); else err = -ENXIO; - up(®ister_mutex); + mutex_unlock(®ister_mutex); return err; } } @@ -375,7 +376,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, return err; } init_waitqueue_head(&hwdep->open_wait); - init_MUTEX(&hwdep->open_mutex); + mutex_init(&hwdep->open_mutex); *rhwdep = hwdep; return 0; } @@ -401,9 +402,9 @@ static int snd_hwdep_dev_register(struct snd_device *device) int err; char name[32]; - down(®ister_mutex); + mutex_lock(®ister_mutex); if (snd_hwdep_search(hwdep->card, hwdep->device)) { - up(®ister_mutex); + mutex_unlock(®ister_mutex); return -EBUSY; } list_add_tail(&hwdep->list, &snd_hwdep_devices); @@ -414,7 +415,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", hwdep->card->number, hwdep->device); list_del(&hwdep->list); - up(®ister_mutex); + mutex_unlock(®ister_mutex); return err; } #ifdef CONFIG_SND_OSSEMUL @@ -434,7 +435,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) } } #endif - up(®ister_mutex); + mutex_unlock(®ister_mutex); return 0; } @@ -443,9 +444,9 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) struct snd_hwdep *hwdep = device->device_data; snd_assert(hwdep != NULL, return -ENXIO); - down(®ister_mutex); + mutex_lock(®ister_mutex); if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { - up(®ister_mutex); + mutex_unlock(®ister_mutex); return -EINVAL; } #ifdef CONFIG_SND_OSSEMUL @@ -454,7 +455,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) #endif snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); list_del(&hwdep->list); - up(®ister_mutex); + mutex_unlock(®ister_mutex); return snd_hwdep_free(hwdep); } @@ -469,13 +470,13 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry, struct list_head *p; struct snd_hwdep *hwdep; - down(®ister_mutex); + mutex_lock(®ister_mutex); list_for_each(p, &snd_hwdep_devices) { hwdep = list_entry(p, struct snd_hwdep, list); snd_iprintf(buffer, "%02i-%02i: %s\n", hwdep->card->number, hwdep->device, hwdep->name); } - up(®ister_mutex); + mutex_unlock(®ister_mutex); } static struct snd_info_entry *snd_hwdep_proc_entry; diff --git a/sound/core/info.c b/sound/core/info.c index af123e3bdb2..2582b74d319 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -31,6 +31,7 @@ #include <sound/version.h> #include <linux/proc_fs.h> #include <linux/devfs_fs_kernel.h> +#include <linux/mutex.h> #include <stdarg.h> /* @@ -68,7 +69,7 @@ int snd_info_check_reserved_words(const char *str) return 1; } -static DECLARE_MUTEX(info_mutex); +static DEFINE_MUTEX(info_mutex); struct snd_info_private_data { struct snd_info_buffer *rbuffer; @@ -265,11 +266,11 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) struct proc_dir_entry *p; int mode, err; - down(&info_mutex); + mutex_lock(&info_mutex); p = PDE(inode); entry = p == NULL ? NULL : (struct snd_info_entry *)p->data; if (entry == NULL || entry->disconnected) { - up(&info_mutex); + mutex_unlock(&info_mutex); return -ENODEV; } if (!try_module_get(entry->module)) { @@ -361,13 +362,13 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) break; } file->private_data = data; - up(&info_mutex); + mutex_unlock(&info_mutex); if (entry->content == SNDRV_INFO_CONTENT_TEXT && (mode == O_RDONLY || mode == O_RDWR)) { if (entry->c.text.read) { - down(&entry->access); + mutex_lock(&entry->access); entry->c.text.read(entry, data->rbuffer); - up(&entry->access); + mutex_unlock(&entry->access); } } return 0; @@ -375,7 +376,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) __error: module_put(entry->module); __error1: - up(&info_mutex); + mutex_unlock(&info_mutex); return err; } @@ -747,7 +748,7 @@ static struct snd_info_entry *snd_info_create_entry(const char *name) } entry->mode = S_IFREG | S_IRUGO; entry->content = SNDRV_INFO_CONTENT_TEXT; - init_MUTEX(&entry->access); + mutex_init(&entry->access); return entry; } @@ -896,10 +897,10 @@ int snd_info_register(struct snd_info_entry * entry) snd_assert(entry != NULL, return -ENXIO); root = entry->parent == NULL ? snd_proc_root : entry->parent->p; - down(&info_mutex); + mutex_lock(&info_mutex); p = snd_create_proc_entry(entry->name, entry->mode, root); if (!p) { - up(&info_mutex); + mutex_unlock(&info_mutex); return -ENOMEM; } p->owner = entry->module; @@ -908,7 +909,7 @@ int snd_info_register(struct snd_info_entry * entry) p->size = entry->size; p->data = entry; entry->p = p; - up(&info_mutex); + mutex_unlock(&info_mutex); return 0; } @@ -929,9 +930,9 @@ int snd_info_unregister(struct snd_info_entry * entry) snd_assert(entry->p != NULL, return -ENXIO); root = entry->parent == NULL ? snd_proc_root : entry->parent->p; snd_assert(root, return -ENXIO); - down(&info_mutex); + mutex_lock(&info_mutex); snd_remove_proc_entry(root, entry->p); - up(&info_mutex); + mutex_unlock(&info_mutex); snd_info_free_entry(entry); return 0; } diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c index 820f4772e44..f9ce854b3d1 100644 --- a/sound/core/info_oss.c +++ b/sound/core/info_oss.c @@ -28,6 +28,7 @@ #include <sound/info.h> #include <sound/version.h> #include <linux/utsname.h> +#include <linux/mutex.h> #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) @@ -35,7 +36,7 @@ * OSS compatible part */ -static DECLARE_MUTEX(strings); +static DEFINE_MUTEX(strings); static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT]; static struct snd_info_entry *snd_sndstat_proc_entry; @@ -45,7 +46,7 @@ int snd_oss_info_register(int dev, int num, char *string) snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO); snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO); - down(&strings); + mutex_lock(&strings); if (string == NULL) { if ((x = snd_sndstat_strings[num][dev]) != NULL) { kfree(x); @@ -54,12 +55,12 @@ int snd_oss_info_register(int dev, int num, char *string) } else { x = kstrdup(string, GFP_KERNEL); if (x == NULL) { - up(&strings); + mutex_unlock(&strings); return -ENOMEM; } } snd_sndstat_strings[num][dev] = x; - up(&strings); + mutex_unlock(&strings); return 0; } @@ -71,7 +72,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d char *str; snd_iprintf(buf, "\n%s:", id); - down(&strings); + mutex_lock(&strings); for (idx = 0; idx < SNDRV_CARDS; idx++) { str = snd_sndstat_strings[idx][dev]; if (str) { @@ -82,7 +83,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d snd_iprintf(buf, "%i: %s\n", idx, str); } } - up(&strings); + mutex_unlock(&strings); if (ok < 0) snd_iprintf(buf, " NOT ENABLED IN CONFIG\n"); return ok; diff --git a/sound/core/init.c b/sound/core/init.c index 75816688607..17fbd6c14fb 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, init_waitqueue_head(&card->shutdown_sleep); INIT_WORK(&card->free_workq, snd_card_free_thread, card); #ifdef CONFIG_PM - init_MUTEX(&card->power_lock); + mutex_init(&card->power_lock); init_waitqueue_head(&card->power_sleep); #endif /* the control interface cannot be accessed from the user space until */ diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 19b3dcbb09c..9f2b88cb587 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -31,7 +31,7 @@ #include <asm/uaccess.h> #include <linux/dma-mapping.h> #include <linux/moduleparam.h> -#include <asm/semaphore.h> +#include <linux/mutex.h> #include <sound/memalloc.h> #ifdef CONFIG_SBUS #include <asm/sbus.h> @@ -54,7 +54,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab); /* */ -static DECLARE_MUTEX(list_mutex); +static DEFINE_MUTEX(list_mutex); static LIST_HEAD(mem_list_head); /* buffer preservation list */ @@ -440,7 +440,7 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) snd_assert(dmab, return 0); - down(&list_mutex); + mutex_lock(&list_mutex); list_for_each(p, &mem_list_head) { mem = list_entry(p, struct snd_mem_list, list); if (mem->id == id && @@ -452,11 +452,11 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) if (dmab->dev.dev == NULL) dmab->dev.dev = dev; kfree(mem); - up(&list_mutex); + mutex_unlock(&list_mutex); return dmab->bytes; } } - up(&list_mutex); + mutex_unlock(&list_mutex); return 0; } @@ -477,11 +477,11 @@ int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) mem = kmalloc(sizeof(*mem), GFP_KERNEL); if (! mem) return -ENOMEM; - down(&list_mutex); + mutex_lock(&list_mutex); mem->buffer = *dmab; mem->id = id; list_add_tail(&mem->list, &mem_list_head); - up(&list_mutex); + mutex_unlock(&list_mutex); return 0; } @@ -493,7 +493,7 @@ static void free_all_reserved_pages(void) struct list_head *p; struct snd_mem_list *mem; - down(&list_mutex); + mutex_lock(&list_mutex); while (! list_empty(&mem_list_head)) { p = mem_list_head.next; mem = list_entry(p, struct snd_mem_list, list); @@ -501,7 +501,7 @@ static void free_all_reserved_pages(void) snd_dma_free_pages(&mem->buffer); kfree(mem); } - up(&list_mutex); + mutex_unlock(&list_mutex); } @@ -522,7 +522,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, int devno; static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; - down(&list_mutex); + mutex_lock(&list_mutex); len += snprintf(page + len, count - len, "pages : %li bytes (%li pages per %likB)\n", pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); @@ -537,7 +537,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, " addr = 0x%lx, size = %d bytes\n", (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes); } - up(&list_mutex); + mutex_unlock(&list_mutex); return len; } diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index f08e65a2bff..9c68bc3f97a 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, struct snd_mixer_oss *mixer = entry->private_data; int i; - down(&mixer->reg_mutex); + mutex_lock(&mixer->reg_mutex); for (i = 0; i < SNDRV_OSS_MAX_MIXERS; i++) { struct slot *p; @@ -1110,7 +1110,7 @@ static void snd_mixer_oss_proc_read(struct snd_info_entry *entry, else snd_iprintf(buffer, "\"\" 0\n"); } - up(&mixer->reg_mutex); + mutex_unlock(&mixer->reg_mutex); } static 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, cptr = snd_info_get_str(str, cptr, sizeof(str)); if (! *str) { /* remove the entry */ - down(&mixer->reg_mutex); + mutex_lock(&mixer->reg_mutex); mixer_slot_clear(&mixer->slots[ch]); - up(&mixer->reg_mutex); + mutex_unlock(&mixer->reg_mutex); continue; } snd_info_get_str(idxstr, cptr, sizeof(idxstr)); @@ -1145,7 +1145,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx); continue; } - down(&mixer->reg_mutex); + mutex_lock(&mixer->reg_mutex); slot = (struct slot *)mixer->slots[ch].private_data; if (slot && slot->assigned && 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, kfree(tbl); } __unlock: - up(&mixer->reg_mutex); + mutex_unlock(&mixer->reg_mutex); } } @@ -1288,7 +1288,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL); if (mixer == NULL) return -ENOMEM; - init_MUTEX(&mixer->reg_mutex); + mutex_init(&mixer->reg_mutex); sprintf(name, "mixer%i%i", card->number, 0); if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, card, 0, diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index bc24d028f51..f8302b703a3 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, const char *ptr, *ptrl; struct snd_pcm_oss_setup *setup; - down(&pcm->streams[stream].oss.setup_mutex); + mutex_lock(&pcm->streams[stream].oss.setup_mutex); for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { if (!strcmp(setup->task_name, task_name)) { - up(&pcm->streams[stream].oss.setup_mutex); + mutex_unlock(&pcm->streams[stream].oss.setup_mutex); return setup; } } @@ -1662,12 +1662,12 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, } for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { if (!strcmp(setup->task_name, ptrl)) { - up(&pcm->streams[stream].oss.setup_mutex); + mutex_unlock(&pcm->streams[stream].oss.setup_mutex); return setup; } } __not_found: - up(&pcm->streams[stream].oss.setup_mutex); + mutex_unlock(&pcm->streams[stream].oss.setup_mutex); return NULL; } @@ -1895,7 +1895,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) init_waitqueue_entry(&wait, current); add_wait_queue(&pcm->open_wait, &wait); - down(&pcm->open_mutex); + mutex_lock(&pcm->open_mutex); while (1) { err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, iminor(inode), psetup, csetup); @@ -1909,16 +1909,16 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) } else break; set_current_state(TASK_INTERRUPTIBLE); - up(&pcm->open_mutex); + mutex_unlock(&pcm->open_mutex); schedule(); - down(&pcm->open_mutex); + mutex_lock(&pcm->open_mutex); if (signal_pending(current)) { err = -ERESTARTSYS; break; } } remove_wait_queue(&pcm->open_wait, &wait); - up(&pcm->open_mutex); + mutex_unlock(&pcm->open_mutex); if (err < 0) goto __error; return err; @@ -1944,9 +1944,9 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) snd_assert(substream != NULL, return -ENXIO); pcm = substream->pcm; snd_pcm_oss_sync(pcm_oss_file); - down(&pcm->open_mutex); + mutex_lock(&pcm->open_mutex); snd_pcm_oss_release_file(pcm_oss_file); - up(&pcm->open_mutex); + mutex_unlock(&pcm->open_mutex); wake_up(&pcm->open_wait); module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); @@ -2293,7 +2293,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, { struct snd_pcm_str *pstr = entry->private_data; struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; - down(&pstr->oss.setup_mutex); + mutex_lock(&pstr->oss.setup_mutex); while (setup) { snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", setup->task_name, @@ -2307,7 +2307,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, setup->nosilence ? " no-silence" : ""); setup = setup->next; } - up(&pstr->oss.setup_mutex); + mutex_unlock(&pstr->oss.setup_mutex); } static 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, struct snd_pcm_oss_setup *setup, *setup1, template; while (!snd_info_get_line(buffer, line, sizeof(line))) { - down(&pstr->oss.setup_mutex); + mutex_lock(&pstr->oss.setup_mutex); memset(&template, 0, sizeof(template)); ptr = snd_info_get_str(task_name, line, sizeof(task_name)); if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) { snd_pcm_oss_proc_free_setup_list(pstr); - up(&pstr->oss.setup_mutex); + mutex_unlock(&pstr->oss.setup_mutex); continue; } 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, } if (setup) *setup = template; - up(&pstr->oss.setup_mutex); + mutex_unlock(&pstr->oss.setup_mutex); } } diff --git a/sound/core/pcm.c b/sound/core/pcm.c index d92c3ce4a4c..f903d1bd74d 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -23,6 +23,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/time.h> +#include <linux/mutex.h> #include <sound/core.h> #include <sound/minors.h> #include <sound/pcm.h> @@ -35,7 +36,7 @@ MODULE_LICENSE("GPL"); static LIST_HEAD(snd_pcm_devices); static LIST_HEAD(snd_pcm_notify_list); -static DECLARE_MUTEX(register_mutex); +static DEFINE_MUTEX(register_mutex); static int snd_pcm_free(struct snd_pcm *pcm); static int snd_pcm_dev_free(struct snd_device *device); @@ -67,7 +68,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)arg)) return -EFAULT; - down(®ister_mutex); + mutex_lock(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_PCM_DEVICES) { if (snd_pcm_search(card, device)) @@ -76,7 +77,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, } if (device == SNDRV_PCM_DEVICES) device = -1; - up(®ister_mutex); + mutex_unlock(®ister_mutex); if (put_user(device, (int __user *)arg)) return -EFAULT; return 0; @@ -100,7 +101,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, return -EINVAL; if (get_user(subdevice, &info->subdevice)) return -EFAULT; - down(®ister_mutex); + mutex_lock(®ister_mutex); pcm = snd_pcm_search(card, device); if (pcm == NULL) { err |