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>
*/
#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 */
#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
#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)
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;
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)
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;
/* --- */
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);
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;
};
#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"
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;
spinlock_t lock;
spinlock_t ops_lock;
- struct semaphore ops_mutex;
+ struct mutex ops_mutex;
unsigned long ops_flags;
};
#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>
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);
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;
} 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;
hw->ops.release(hw, file);
}
}
- up(&hw->open_mutex);
+ mutex_unlock(&hw->open_mutex);
if (err < 0)
module_put(hw->card->module);
return err;
{
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);
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;
}
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))
}
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;
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;
}
}
return err;
}
init_waitqueue_head(&hwdep->open_wait);
- init_MUTEX(&hwdep->open_mutex);
+ mutex_init(&hwdep->open_mutex);
*rhwdep = hwdep;
return 0;
}
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);
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
}
}
#endif
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
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
#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);
}
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;
#include <sound/version.h>
#include <linux/proc_fs.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/mutex.h>
#include <stdarg.h>
/*
return 1;
}
-static DECLARE_MUTEX(info_mutex);
+static DEFINE_MUTEX(info_mutex);
struct snd_info_private_data {
struct snd_info_buffer *rbuffer;
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)) {
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;
__error:
module_put(entry->module);
__error1:
- up(&info_mutex);
+ mutex_unlock(&info_mutex);
return err;
}
}
entry->mode = S_IFREG | S_IRUGO;
entry->content = SNDRV_INFO_CONTENT_TEXT;
- init_MUTEX(&entry->access);
+ mutex_init(&entry->access);
return 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;
p->size = entry->size;
p->data = entry;
entry->p = p;
- up(&info_mutex);
+ mutex_unlock(&info_mutex);
return 0;
}
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;
}
#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)
* 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;
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);
} 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;
}
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) {
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;
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 */
#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>
/*
*/
-static DECLARE_MUTEX(list_mutex);
+static DEFINE_MUTEX(list_mutex);
static LIST_HEAD(mem_list_head);
/* buffer preservation list */
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 &&
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;
}
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;
}
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);
snd_dma_free_pages(&mem->buffer);
kfree(mem);
}
- up(&list_mutex);
+ mutex_unlock(&list_mutex);
}
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);
" 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;
}
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;
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,
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));
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))
kfree(tbl);
}
__unlock:
- up(&mixer->reg_mutex);
+ mutex_unlock(&mixer->reg_mutex);
}
}
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,
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;
}
}
}
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;
}
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);
} 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;
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);
{
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,
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)
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) {
}
if (setup)
*setup = template;
- up(&pstr->oss.setup_mutex);
+ mutex_unlock(&pstr->oss.setup_mutex);
}
}
#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>
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);
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))
}
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;
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 = -ENXIO;
}
err = snd_pcm_info_user(substream, info);
_error:
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return err;
}
case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE:
#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
#include <linux/soundcard.h>
+
static const char *snd_pcm_oss_format_name(int format)
{
switch (format) {
struct snd_pcm_substream *substream, *prev;
#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
- init_MUTEX(&pstr->oss.setup_mutex);
+ mutex_init(&pstr->oss.setup_mutex);
#endif
pstr->stream = stream;
pstr->pcm = pcm;
snd_pcm_free(pcm);
return err;
}
- init_MUTEX(&pcm->open_mutex);
+ mutex_init(&pcm->open_mutex);
init_waitqueue_head(&pcm->open_wait);
if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) {
snd_pcm_free(pcm);
struct snd_pcm *pcm = device->device_data;
snd_assert(pcm != NULL && device != NULL, return -ENXIO);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
if (snd_pcm_search(pcm->card, pcm->device)) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -EBUSY;
}
list_add_tail(&pcm->list, &snd_pcm_devices);
pcm, str)) < 0)
{
list_del(&pcm->list);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return err;
}
for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
notify = list_entry(list, struct snd_pcm_notify, list);
notify->n_register(pcm);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
struct snd_pcm_substream *substream;
int cidx;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_del_init(&pcm->list);
for (cidx = 0; cidx < 2; cidx++)
for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
notify = list_entry(list, struct snd_pcm_notify, list);
notify->n_disconnect(pcm);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
struct snd_pcm *pcm = device->device_data;
snd_assert(pcm != NULL, return -ENXIO);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_del(&pcm->list);
for (cidx = 0; cidx < 2; cidx++) {
devtype = -1;
notify = list_entry(list, struct snd_pcm_notify, list);
notify->n_unregister(pcm);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return snd_pcm_free(pcm);
}
struct list_head *p;
snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
if (nfree) {
list_del(¬ify->list);
list_for_each(p, &snd_pcm_devices)
list_for_each(p, &snd_pcm_devices)
notify->n_register(list_entry(p, struct snd_pcm, list));
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
struct list_head *p;
struct snd_pcm *pcm;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_for_each(p, &snd_pcm_devices) {
pcm = list_entry(p, struct snd_pcm, list);
snd_iprintf(buffer, "%02i-%02i: %s : %s",
pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count);
snd_iprintf(buffer, "\n");
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
}
static struct snd_info_entry *snd_pcm_proc_entry = NULL;
}
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_open_file(file, pcm, stream, &pcm_file);
if (err >= 0)
} 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;
pcm = substream->pcm;
snd_pcm_drop(substream);
fasync_helper(-1, file, 0, &substream->runtime->fasync);
- down(&pcm->open_mutex);
+ mutex_lock(&pcm->open_mutex);
snd_pcm_release_file(pcm_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);
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/wait.h>
+#include <linux/mutex.h>
#include <linux/moduleparam.h>
#include <linux/delay.h>
#include <linux/wait.h>
static int snd_rawmidi_dev_unregister(struct snd_device *device);
static LIST_HEAD(snd_rawmidi_devices);
-static DECLARE_MUTEX(register_mutex);
+static DEFINE_MUTEX(register_mutex);
static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
{
if (rfile)
rfile->input = rfile->output = NULL;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
rmidi = snd_rawmidi_search(card, device);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
if (rmidi == NULL) {
err = -ENODEV;
goto __error1;
goto __error1;
}
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
- down(&rmidi->open_mutex);
+ mutex_lock(&rmidi->open_mutex);
if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) {
err = -ENXIO;
soutput = NULL;
}
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
- up(&rmidi->open_mutex);
+ mutex_unlock(&rmidi->open_mutex);
if (rfile) {
rfile->rmidi = rmidi;
rfile->input = sinput;
snd_rawmidi_runtime_free(soutput);
module_put(rmidi->card->module);
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
- up(&rmidi->open_mutex);
+ mutex_unlock(&rmidi->open_mutex);
__error1:
return err;
}
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&rmidi->open_wait, &wait);
- down(&rmidi->open_mutex);
+ mutex_lock(&rmidi->open_mutex);
while (1) {
subdevice = -1;
down_read(&card->controls_rwsem);
} else
break;
set_current_state(TASK_INTERRUPTIBLE);
- up(&rmidi->open_mutex);
+ mutex_unlock(&rmidi->open_mutex);
schedule();
- down(&rmidi->open_mutex);
+ mutex_lock(&rmidi->open_mutex);
if (signal_pending(current)) {
err = -ERESTARTSYS;
break;
snd_card_file_remove(card, file);
kfree(rawmidi_file);
}
- up(&rmidi->open_mutex);
+ mutex_unlock(&rmidi->open_mutex);
return err;
}
snd_assert(rfile != NULL, return -ENXIO);
snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO);
rmidi = rfile->rmidi;
- down(&rmidi->open_mutex);
+ mutex_lock(&rmidi->open_mutex);
if (rfile->input != NULL) {
substream = rfile->input;
rfile->input = NULL;
}
rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--;
}
- up(&rmidi->open_mutex);
+ mutex_unlock(&rmidi->open_mutex);
module_put(rmidi->card->module);
return 0;
}
struct snd_rawmidi_substream *substream;
struct list_head *list;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
rmidi = snd_rawmidi_search(card, info->device);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
if (!rmidi)
return -ENXIO;
if (info->stream < 0 || info->stream > 1)
if (get_user(device, (int __user *)argp))
return -EFAULT;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
device = device < 0 ? 0 : device + 1;
while (device < SNDRV_RAWMIDI_DEVICES) {
if (snd_rawmidi_search(card, device))
}
if (device == SNDRV_RAWMIDI_DEVICES)
device = -1;
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
if (put_user(device, (int __user *)argp))
return -EFAULT;
return 0;
rmidi = entry->private_data;
snd_iprintf(buffer, "%s\n\n", rmidi->name);
- down(&rmidi->open_mutex);
+ mutex_lock(&rmidi->open_mutex);
if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) {
substream = list_entry(list, struct snd_rawmidi_substream, list);
}
}
}
- up(&rmidi->open_mutex);
+ mutex_unlock(&rmidi->open_mutex);
}
/*
}
rmidi->card = card;
rmidi->device = device;
- init_MUTEX(&rmidi->open_mutex);
+ mutex_init(&rmidi->open_mutex);
init_waitqueue_head(&rmidi->open_wait);
if (id != NULL)
strlcpy(rmidi->id, id, sizeof(rmidi->id));
if (rmidi->device >= SNDRV_RAWMIDI_DEVICES)
return -ENOMEM;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
if (snd_rawmidi_search(rmidi->card, rmidi->device)) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -EBUSY;
}
list_add_tail(&rmidi->list, &snd_rawmidi_devices);
&snd_rawmidi_f_ops, rmidi, name)) < 0) {
snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
list_del(&rmidi->list);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return err;
}
if (rmidi->ops && rmidi->ops->dev_register &&
(err = rmidi->ops->dev_register(rmidi)) < 0) {
snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
list_del(&rmidi->list);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return err;
}
#ifdef CONFIG_SND_OSSEMUL
}
}
#endif /* CONFIG_SND_OSSEMUL */
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
sprintf(name, "midi%d", rmidi->device);
entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root);
if (entry) {
{
struct snd_rawmidi *rmidi = device->device_data;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_del_init(&rmidi->list);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
struct snd_rawmidi *rmidi = device->device_data;
snd_assert(rmidi != NULL, return -ENXIO);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_del(&rmidi->list);
if (rmidi->proc_entry) {
snd_info_unregister(rmidi->proc_entry);
if (rmidi->ops && rmidi->ops->dev_unregister)
rmidi->ops->dev_unregister(rmidi);
snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
if (rmidi->seq_dev) {
snd_device_free(rmidi->card, rmidi->seq_dev);
#include <linux/init.h>
#include <linux/smp_lock.h>
#include <linux/moduleparam.h>
+#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/minors.h>
#include <sound/initval.h>
* ALSA minor device interface
*/
-static DECLARE_MUTEX(register_mutex);
+static DEFINE_MUTEX(register_mutex);
static int
odev_open(struct inode *inode, struct file *file)
else
level = SNDRV_SEQ_OSS_MODE_SYNTH;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
rc = snd_seq_oss_open(file, level);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return rc;
}
snd_seq_oss_drain_write(dp);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
snd_seq_oss_release(dp);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
{
int rc;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
NULL, 0,
&seq_oss_f_ops, NULL,
SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device seq\n");
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return rc;
}
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device music\n");
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return rc;
}
debug_printk(("device registered\n"));
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
static void
unregister_device(void)
{
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
debug_printk(("device unregistered\n"));
if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0)
snd_printk(KERN_ERR "error unregister device music\n");
if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0)
snd_printk(KERN_ERR "error unregister device seq\n");
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
}
/*
static void
info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf)
{
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR);
snd_seq_oss_system_info_read(buf);
snd_seq_oss_synth_info_read(buf);
snd_seq_oss_midi_info_read(buf);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
}
#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT)
static DEFINE_SPINLOCK(clients_lock);
-static DECLARE_MUTEX(register_mutex);
+static DEFINE_MUTEX(register_mutex);
/*
* client table
client->type = NO_CLIENT;
snd_use_lock_init(&client->use_lock);
rwlock_init(&client->ports_lock);
- init_MUTEX(&client->ports_mutex);
+ mutex_init(&client->ports_mutex);
INIT_LIST_HEAD(&client->ports_list_head);
/* find free slot in the client table */
static void seq_free_client(struct snd_seq_client * client)
{
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
switch (client->type) {
case NO_CLIENT:
snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n",
snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n",
client->number, client->type);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
snd_seq_system_client_ev_client_exit(client->number);
}
struct snd_seq_client *client;
struct snd_seq_user_client *user;
- if (down_interruptible(®ister_mutex))
+ if (mutex_lock_interruptible(®ister_mutex))
return -ERESTARTSYS;
client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS);
if (client == NULL) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENOMEM; /* failure code */
}
if (user->fifo == NULL) {
seq_free_client1(client);
kfree(client);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENOMEM;
}
}
usage_alloc(&client_usage, 1);
client->type = USER_CLIENT;
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
c = client->number;
file->private_data = client;
if (queue == NULL)
return -EINVAL;
- if (down_interruptible(&queue->timer_mutex)) {
+ if (mutex_lock_interruptible(&queue->timer_mutex)) {
queuefree(queue);
return -ERESTARTSYS;
}
timer.u.alsa.id = tmr->alsa_id;
timer.u.alsa.resolution = tmr->preferred_resolution;
}
- up(&queue->timer_mutex);
+ mutex_unlock(&queue->timer_mutex);
queuefree(queue);
if (copy_to_user(arg, &timer, sizeof(timer)))
q = queueptr(timer.queue);
if (q == NULL)
return -ENXIO;
- if (down_interruptible(&q->timer_mutex)) {
+ if (mutex_lock_interruptible(&q->timer_mutex)) {
queuefree(q);
return -ERESTARTSYS;
}
tmr->preferred_resolution = timer.u.alsa.resolution;
}
result = snd_seq_queue_timer_open(timer.queue);
- up(&q->timer_mutex);
+ mutex_unlock(&q->timer_mutex);
queuefree(q);
} else {
return -EPERM;
if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS)
return -EINVAL;
- if (down_interruptible(®ister_mutex))
+ if (mutex_lock_interruptible(®ister_mutex))
return -ERESTARTSYS;
if (card) {
/* empty write queue as default */
client = seq_create_client1(client_index, 0);
if (client == NULL) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -EBUSY; /* failure code */
}
usage_alloc(&client_usage, 1);
va_end(args);
client->type = KERNEL_CLIENT;
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
/* make others aware this new client */
snd_seq_system_client_ev_client_start(client->number);
{
struct list_head *l;
- down(&client->ports_mutex);
+ mutex_lock(&client->ports_mutex);
list_for_each(l, &client->ports_list_head) {
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n",
snd_seq_info_dump_subscribers(buffer, &p->c_src, 1, " Connecting To: ");
snd_seq_info_dump_subscribers(buffer, &p->c_dest, 0, " Connected From: ");
}
- up(&client->ports_mutex);
+ mutex_unlock(&client->ports_mutex);
}
{
int err;
- if (down_interruptible(®ister_mutex))
+ if (mutex_lock_interruptible(®ister_mutex))
return -ERESTARTSYS;
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
&snd_seq_f_ops, NULL, "seq")) < 0) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return err;
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
int num_ports; /* number of ports */
struct list_head ports_list_head;
rwlock_t ports_lock;
- struct semaphore ports_mutex;
+ struct mutex ports_mutex;
int convert32; /* convert 32->64bit */
/* output pool */
#include <sound/initval.h>
#include <linux/kmod.h>
#include <linux/slab.h>
+#include <linux/mutex.h>
MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
MODULE_DESCRIPTION("ALSA sequencer device management");
struct list_head dev_list; /* list of devices */
int num_devices; /* number of associated devices */
int num_init_devices; /* number of initialized devices */
- struct semaphore reg_mutex;
+ struct mutex reg_mutex;
struct list_head list; /* next driver */
};
static LIST_HEAD(opslist);
static int num_ops;
-static DECLARE_MUTEX(ops_mutex);
+static DEFINE_MUTEX(ops_mutex);
#ifdef CONFIG_PROC_FS
static struct snd_info_entry *info_entry = NULL;
#endif
{
struct list_head *head;
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
list_for_each(head, &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list);
snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
ops->driver & DRIVER_LOCKED ? ",locked" : "",
ops->num_devices);
}
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
}
#endif
if (! current->fs->root)
return;
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
list_for_each(head, &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list);
if (! (ops->driver & DRIVER_LOADED) &&
! (ops->driver & DRIVER_REQUESTED)) {
ops->used++;
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
ops->driver |= DRIVER_REQUESTED;
request_module("snd-%s", ops->id);
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
ops->used--;
}
}
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
#endif
}
dev->status = SNDRV_SEQ_DEVICE_FREE;
/* add this device to the list */
- down(&ops->reg_mutex);
+ mutex_lock(&ops->reg_mutex);
list_add_tail(&dev->list, &ops->dev_list);
ops->num_devices++;
- up(&ops->reg_mutex);
+ mutex_unlock(&ops->reg_mutex);
unlock_driver(ops);
return -ENXIO;
/* remove the device from the list */
- down(&ops->reg_mutex);
+ mutex_lock(&ops->reg_mutex);
list_del(&dev->list);
ops->num_devices--;
- up(&ops->reg_mutex);
+ mutex_unlock(&ops->reg_mutex);
free_device(dev, ops);
if (dev->private_free)
return -EBUSY;
}
- down(&ops->reg_mutex);
+ mutex_lock(&ops->reg_mutex);
/* copy driver operators */
ops->ops = *entry;
ops->driver |= DRIVER_LOADED;
struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
init_device(dev, ops);
}
- up(&ops->reg_mutex);
+ mutex_unlock(&ops->reg_mutex);
unlock_driver(ops);
snd_seq_autoload_unlock();
/* set up driver entry */
strlcpy(ops->id, id, sizeof(ops->id));
- init_MUTEX(&ops->reg_mutex);
+ mutex_init(&ops->reg_mutex);
ops->driver = DRIVER_EMPTY;
INIT_LIST_HEAD(&ops->dev_list);
/* lock this instance */
ops->used = 1;
/* register driver entry */
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
list_add_tail(&ops->list, &opslist);
num_ops++;
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
return ops;
}
}
/* close and release all devices associated with this driver */
- down(&ops->reg_mutex);
+ mutex_lock(&ops->reg_mutex);
ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
list_for_each(head, &ops->dev_list) {
struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
if (ops->num_init_devices > 0)
snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n",
ops->num_init_devices);
- up(&ops->reg_mutex);
+ mutex_unlock(&ops->reg_mutex);
unlock_driver(ops);
{
struct list_head *head;
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
head = opslist.next;
while (head != &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list);
} else
head = head->next;
}
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
}
/*
{
struct list_head *head;
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
list_for_each(head, &opslist) {
struct ops_list *ops = list_entry(head, struct ops_list, list);
if (strcmp(ops->id, id) == 0) {
ops->used++;
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
return ops;
}
}
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
if (create_if_empty)
return create_driver(id);
return NULL;
static void unlock_driver(struct ops_list *ops)
{
- down(&ops_mutex);
+ mutex_lock(&ops_mutex);
ops->used--;
- up(&ops_mutex);
+ mutex_unlock(&ops_mutex);
}
if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
spin_lock_irqsave(&list->ops_lock, list->ops_flags);
} else {
- down(&list->ops_mutex);
+ mutex_lock(&list->ops_mutex);
}
}
if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
spin_unlock_irqrestore(&list->ops_lock, list->ops_flags);
} else {
- up(&list->ops_mutex);
+ mutex_unlock(&list->ops_mutex);
}
}
return NULL;
spin_lock_init(&list->lock);
spin_lock_init(&list->ops_lock);
- init_MUTEX(&list->ops_mutex);
+ mutex_init(&list->ops_mutex);
list->owner = -1;
return list;
}
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/moduleparam.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/rawmidi.h>
#include <sound/seq_kernel.h>
};
static struct seq_midisynth_client *synths[SNDRV_CARDS];
-static DECLARE_MUTEX(register_mutex);
+static DEFINE_MUTEX(register_mutex);
/* handle rawmidi input event (MIDI v1.0 stream) */
static void snd_midi_input_event(struct snd_rawmidi_substream *substream)
if (ports > (256 / SNDRV_RAWMIDI_DEVICES))
ports = 256 / SNDRV_RAWMIDI_DEVICES;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
client = synths[card->number];
if (client == NULL) {
newclient = 1;
client = kzalloc(sizeof(*client), GFP_KERNEL);
if (client == NULL) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
kfree(info);
return -ENOMEM;
}
(const char *)info->name : "External MIDI");
if (client->seq_client < 0) {
kfree(client);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
kfree(info);
return -ENOMEM;
}
client->num_ports++;
if (newclient)
synths[card->number] = client;
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
kfree(info);
kfree(port);
return 0; /* success */
}
kfree(info);
kfree(port);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENOMEM;
}
struct snd_card *card = dev->card;
int device = dev->device, p, ports;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
client = synths[card->number];
if (client == NULL || client->ports[device] == NULL) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENODEV;
}
ports = client->ports_per_device[device];
synths[card->number] = NULL;
kfree(client);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
port_subs_info_init(&new_port->c_dest);
num = port >= 0 ? port : 0;
- down(&client->ports_mutex);
+ mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags);
list_for_each(l, &client->ports_list_head) {
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
client->num_ports++;
new_port->addr.port = num; /* store the port number in the port */
write_unlock_irqrestore(&client->ports_lock, flags);
- up(&client->ports_mutex);
+ mutex_unlock(&client->ports_mutex);
sprintf(new_port->name, "port-%d", num);
return new_port;
struct list_head *l;
struct snd_seq_client_port *found = NULL;
- down(&client->ports_mutex);
+ mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags);
list_for_each(l, &client->ports_list_head) {
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
}
}
write_unlock_irqrestore(&client->ports_lock, flags);
- up(&client->ports_mutex);
+ mutex_unlock(&client->ports_mutex);
if (found)
return port_delete(client, found);
else
/* move the port list to deleted_list, and
* clear the port list in the client data.
*/
- down(&client->ports_mutex);
+ mutex_lock(&client->ports_mutex);
write_lock_irqsave(&client->ports_lock, flags);
if (! list_empty(&client->ports_list_head)) {
__list_add(&deleted_list,
snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
port_delete(client, port);
}
- up(&client->ports_mutex);
+ mutex_unlock(&client->ports_mutex);
return 0;
}
spin_lock_init(&q->owner_lock);
spin_lock_init(&q->check_lock);
- init_MUTEX(&q->timer_mutex);
+ mutex_init(&q->timer_mutex);
snd_use_lock_init(&q->use_lock);
q->queue = -1;
queue = queueptr(queueid);
if (queue == NULL)
return -EINVAL;
- down(&queue->timer_mutex);
+ mutex_lock(&queue->timer_mutex);
if (use) {
if (!test_and_set_bit(client, queue->clients_bitmap))
queue->clients++;
} else {
snd_seq_timer_close(queue);
}
- up(&queue->timer_mutex);
+ mutex_unlock(&queue->timer_mutex);
queuefree(queue);
return 0;
}
/* clients which uses this queue (bitmap) */
DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS);
unsigned int clients; /* users of this queue */
- struct semaphore timer_mutex;
+ struct mutex timer_mutex;
snd_use_lock_t use_lock;
};
#include <sound/initval.h>
#include <linux/kmod.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/mutex.h>
#define SNDRV_OS_MINORS 256
int snd_ecards_limit;
static struct snd_minor *snd_minors[SNDRV_OS_MINORS];
-static DECLARE_MUTEX(sound_mutex);
+static DEFINE_MUTEX(sound_mutex);
extern struct class *sound_class;
if (minor > ARRAY_SIZE(snd_minors))
return NULL;
- down(&sound_mutex);
+ mutex_lock(&sound_mutex);
mreg = snd_minors[minor];
if (mreg && mreg->type == type)
private_data = mreg->private_data;
else
private_data = NULL;
- up(&sound_mutex);
+ mutex_unlock(&sound_mutex);
return private_data;
}
preg->f_ops = f_ops;
preg->private_data = private_data;
strcpy(preg->name, name);
- down(&sound_mutex);
+ mutex_lock(&sound_mutex);
#ifdef CONFIG_SND_DYNAMIC_MINORS
minor = snd_find_free_minor();
#else
minor = -EBUSY;
#endif
if (minor < 0) {
- up(&sound_mutex);
+ mutex_unlock(&sound_mutex);
kfree(preg);
return minor;
}
device = card->dev;
class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);
- up(&sound_mutex);
+ mutex_unlock(&sound_mutex);
return 0;
}
struct snd_minor *mptr;
cardnum = card ? card->number : -1;
- down(&sound_mutex);
+ mutex_lock(&sound_mutex);
for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor)
if ((mptr = snd_minors[minor]) != NULL &&
mptr->type == type &&
mptr->device == dev)
break;
if (minor == ARRAY_SIZE(snd_minors)) {
- up(&sound_mutex);
+ mutex_unlock(&sound_mutex);
return -EINVAL;
}
class_device_destroy(sound_class, MKDEV(major, minor));
snd_minors[minor] = NULL;
- up(&sound_mutex);
+ mutex_unlock(&sound_mutex);
kfree(mptr);
return 0;
}
int minor;
struct snd_minor *mptr;
- down(&sound_mutex);
+ mutex_lock(&sound_mutex);
for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) {
if (!(mptr = snd_minors[minor]))
continue;
snd_iprintf(buffer, "%3i: : %s\n", minor,
snd_device_type_name(mptr->type));
}
- up(&sound_mutex);
+ mutex_unlock(&sound_mutex);
}
int __init snd_minor_info_init(void)
#include <sound/minors.h>
#include <sound/info.h>
#include <linux/sound.h>
+#include <linux/mutex.h>
#define SNDRV_OSS_MINORS 128
static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
-static DECLARE_MUTEX(sound_oss_mutex);
+static DEFINE_MUTEX(sound_oss_mutex);
void *snd_lookup_oss_minor_data(unsigned int minor, int type)
{
if (minor > ARRAY_SIZE(snd_oss_minors))
return NULL;
- down(&sound_oss_mutex);
+ mutex_lock(&sound_oss_mutex);
mreg = snd_oss_minors[minor];
if (mreg && mreg->type == type)
private_data = mreg->private_data;
else
private_data = NULL;
- up(&sound_oss_mutex);
+ mutex_unlock(&sound_oss_mutex);
return private_data;
}
preg->device = dev;
preg->f_ops = f_ops;
preg->private_data = private_data;
- down(&sound_oss_mutex);
+ mutex_lock(&sound_oss_mutex);
snd_oss_minors[minor] = preg;
minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
switch (minor_unit) {
goto __end;
snd_oss_minors[track2] = preg;
}
- up(&sound_oss_mutex);
+ mutex_unlock(&sound_oss_mutex);
return 0;
__end:
if (register1 >= 0)
unregister_sound_special(register1);
snd_oss_minors[minor] = NULL;
- up(&sound_oss_mutex);
+ mutex_unlock(&sound_oss_mutex);
kfree(preg);
return -EBUSY;
}
return 0;
if (minor < 0)
return minor;
- down(&sound_oss_mutex);
+ mutex_lock(&sound_oss_mutex);
mptr = snd_oss_minors[minor];
if (mptr == NULL) {
- up(&sound_oss_mutex);
+ mutex_unlock(&sound_oss_mutex);
return -ENOENT;
}
unregister_sound_special(minor);
snd_oss_minors[track2] = NULL;
}
snd_oss_minors[minor] = NULL;
- up(&sound_oss_mutex);
+ mutex_unlock(&sound_oss_mutex);
kfree(mptr);
return 0;
}
int minor;
struct snd_minor *mptr;
- down(&sound_oss_mutex);
+ mutex_lock(&sound_oss_mutex);
for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) {
if (!(mptr = snd_oss_minors[minor]))
continue;
snd_iprintf(buffer, "%3i: : %s\n", minor,
snd_oss_device_type_name(mptr->type));
}
- up(&sound_oss_mutex);
+ mutex_unlock(&sound_oss_mutex);
}
#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/mutex.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <sound/core.h>
struct timespec tstamp; /* trigger tstamp */
wait_queue_head_t qchange_sleep;
struct fasync_struct *fasync;
- struct semaphore tread_sem;
+ struct mutex tread_sem;
};
/* list of timers */
/* lock for slave active lists */
static DEFINE_SPINLOCK(slave_active_lock);
-static DECLARE_MUTEX(register_mutex);
+static DEFINE_MUTEX(register_mutex);
static int snd_timer_free(struct snd_timer *timer);
static int snd_timer_dev_free(struct snd_device *device);
snd_printd("invalid slave class %i\n", tid->dev_sclass);
return -EINVAL;
}
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
timeri = snd_timer_instance_new(owner, NULL);
if (!timeri) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENOMEM;
}
timeri->slave_class = tid->dev_sclass;
timeri->flags |= SNDRV_TIMER_IFLG_SLAVE;
list_add_tail(&timeri->open_list, &snd_timer_slave_list);
snd_timer_check_slave(timeri);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
*ti = timeri;
return 0;
}
/* open a master instance */
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
timer = snd_timer_find(tid);
#ifdef CONFIG_KMOD
if (timer == NULL) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
snd_timer_request(tid);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
timer = snd_timer_find(tid);
}
#endif
if (!timer) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENODEV;
}
if (!list_empty(&timer->open_list_head)) {
timeri = list_entry(timer->open_list_head.next,
struct snd_timer_instance, open_list);
if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -EBUSY;
}
}
timeri = snd_timer_instance_new(owner, timer);
if (!timeri) {
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -ENOMEM;
}
timeri->slave_class = tid->dev_sclass;
timer->hw.open(timer);
list_add_tail(&timeri->open_list, &timer->open_list_head);
snd_timer_check_master(timeri);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
*ti = timeri;
return 0;
}
spin_lock_irq(&slave_active_lock);
}
spin_unlock_irq(&slave_active_lock);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_del(&timeri->open_list);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
} else {
timer = timeri->timer;
/* wait, until the active callback is finished */
spin_lock_irq(&timer->lock);
}
spin_unlock_irq(&timer->lock);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_del(&timeri->open_list);
if (timer && list_empty(&timer->open_list_head) &&
timer->hw.close)
slave->timer = NULL;
spin_unlock_irq(&slave_active_lock);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
}
if (timeri->private_free)
timeri->private_free(timeri);
!timer->hw.resolution && timer->hw.c_resolution == NULL)
return -EINVAL;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_for_each(p, &snd_timer_list) {
timer1 = list_entry(p, struct snd_timer, device_list);
if (timer1->tmr_class > timer->tmr_class)
if (timer1->tmr_subdevice < timer->tmr_subdevice)
continue;
/* conflicts.. */
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return -EBUSY;
}
list_add_tail(&timer->device_list, p);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return 0;
}
struct snd_timer_instance *ti;
snd_assert(timer != NULL, return -ENXIO);
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
if (! list_empty(&timer->open_list_head)) {
snd_printk(KERN_WARNING "timer 0x%lx is busy?\n", (long)timer);
list_for_each_safe(p, n, &timer->open_list_head) {
}
}
list_del(&timer->device_list);
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return snd_timer_free(timer);
}
struct snd_timer_instance *ti;
struct list_head *p, *q;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
list_for_each(p, &snd_timer_list) {
timer = list_entry(p, struct snd_timer, device_list);
switch (timer->tmr_class) {
}
spin_unlock_irqrestore(&timer->lock, flags);
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
}
static struct snd_info_entry *snd_timer_proc_entry = NULL;
return -ENOMEM;
spin_lock_init(&tu->qlock);
init_waitqueue_head(&tu->qchange_sleep);
- init_MUTEX(&tu->tread_sem);
+ mutex_init(&tu->tread_sem);
tu->ticks = 1;
tu->queue_size = 128;
tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read),
if (copy_from_user(&id, _tid, sizeof(id)))
return -EFAULT;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
if (id.dev_class < 0) { /* first item */
if (list_empty(&snd_timer_list))
snd_timer_user_zero_id(&id);
snd_timer_user_zero_id(&id);
}
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
if (copy_to_user(_tid, &id, sizeof(*_tid)))
return -EFAULT;
return 0;
tid = ginfo->tid;
memset(ginfo, 0, sizeof(*ginfo));
ginfo->tid = tid;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
t = snd_timer_find(&tid);
if (t != NULL) {
ginfo->card = t->card ? t->card->number : -1;
} else {
err = -ENODEV;
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
err = -EFAULT;
kfree(ginfo);
if (copy_from_user(&gparams, _gparams, sizeof(gparams)))
return -EFAULT;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
t = snd_timer_find(&gparams.tid);
if (!t) {
err = -ENODEV;
}
err = t->hw.set_period(t, gparams.period_num, gparams.period_den);
_error:
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
return err;
}
tid = gstatus.tid;
memset(&gstatus, 0, sizeof(gstatus));
gstatus.tid = tid;
- down(®ister_mutex);
+ mutex_lock(®ister_mutex);
t = snd_timer_find(&tid);
if (t != NULL) {
if (t->hw.c_resolution)
} else {
err = -ENODEV;
}
- up(®ister_mutex);
+ mutex_unlock(®ister_mutex);
if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus)))
err = -EFAULT;
return err;
int err = 0;
tu = file->private_data;
- down(&tu->tread_sem);
+ mutex_lock(&tu->tread_sem);
if (tu->timeri) {
snd_timer_close(tu->timeri);
tu->timeri = NULL;
}
__err:
- up(&tu->tread_sem);
+ mutex_unlock(&tu->tread_sem);
return err;
}
{
int xarg;
- down(&tu->tread_sem);
+ mutex_lock(&tu->tread_sem);
if (tu->timeri) { /* too late */
- up(&tu->tread_sem);
+ mutex_unlock(&tu->tread_sem);
return -EBUSY;
}
if (get_user(xarg, p)) {
- up(&tu->tread_sem);
+ mutex_unlock(&tu->tread_sem);
return -EFAULT;
}
tu->tread = xarg ? 1 : 0;
- up(&tu->tread_sem);
+ mutex_unlock(&tu->tread_sem);
return 0;
}
case SNDRV_TIMER_IOCTL_GINFO: