aboutsummaryrefslogtreecommitdiff
path: root/sound/core/timer.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-01-16 16:29:08 +0100
committerJaroslav Kysela <perex@suse.cz>2006-03-22 10:24:50 +0100
commit1a60d4c5a0c4028559585a74e48593b16e1ca9b2 (patch)
treef03f8dfcd554f8ebbb295522dc46dfe4d110a484 /sound/core/timer.c
parentf0283f45a04d5cf31512e5e390a38504d97e7a97 (diff)
[ALSA] semaphore -> mutex (core part)
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/timer.c')
-rw-r--r--sound/core/timer.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 2425b971b24..cdeeb639b67 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -25,6 +25,7 @@
#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>
@@ -70,7 +71,7 @@ struct snd_timer_user {
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 */
@@ -82,7 +83,7 @@ static LIST_HEAD(snd_timer_slave_list);
/* 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);
@@ -252,10 +253,10 @@ int snd_timer_open(struct snd_timer_instance **ti,
snd_printd("invalid slave class %i\n", tid->dev_sclass);
return -EINVAL;
}
- down(&register_mutex);
+ mutex_lock(&register_mutex);
timeri = snd_timer_instance_new(owner, NULL);
if (!timeri) {
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
return -ENOMEM;
}
timeri->slave_class = tid->dev_sclass;
@@ -263,37 +264,37 @@ int snd_timer_open(struct snd_timer_instance **ti,
timeri->flags |= SNDRV_TIMER_IFLG_SLAVE;
list_add_tail(&timeri->open_list, &snd_timer_slave_list);
snd_timer_check_slave(timeri);
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
*ti = timeri;
return 0;
}
/* open a master instance */
- down(&register_mutex);
+ mutex_lock(&register_mutex);
timer = snd_timer_find(tid);
#ifdef CONFIG_KMOD
if (timer == NULL) {
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
snd_timer_request(tid);
- down(&register_mutex);
+ mutex_lock(&register_mutex);
timer = snd_timer_find(tid);
}
#endif
if (!timer) {
- up(&register_mutex);
+ mutex_unlock(&register_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(&register_mutex);
+ mutex_unlock(&register_mutex);
return -EBUSY;
}
}
timeri = snd_timer_instance_new(owner, timer);
if (!timeri) {
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
return -ENOMEM;
}
timeri->slave_class = tid->dev_sclass;
@@ -302,7 +303,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
timer->hw.open(timer);
list_add_tail(&timeri->open_list, &timer->open_list_head);
snd_timer_check_master(timeri);
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
*ti = timeri;
return 0;
}
@@ -333,9 +334,9 @@ int snd_timer_close(struct snd_timer_instance *timeri)
spin_lock_irq(&slave_active_lock);
}
spin_unlock_irq(&slave_active_lock);
- down(&register_mutex);
+ mutex_lock(&register_mutex);
list_del(&timeri->open_list);
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
} else {
timer = timeri->timer;
/* wait, until the active callback is finished */
@@ -346,7 +347,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
spin_lock_irq(&timer->lock);
}
spin_unlock_irq(&timer->lock);
- down(&register_mutex);
+ mutex_lock(&register_mutex);
list_del(&timeri->open_list);
if (timer && list_empty(&timer->open_list_head) &&
timer->hw.close)
@@ -362,7 +363,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
slave->timer = NULL;
spin_unlock_irq(&slave_active_lock);
}
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
}
if (timeri->private_free)
timeri->private_free(timeri);
@@ -835,7 +836,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
!timer->hw.resolution && timer->hw.c_resolution == NULL)
return -EINVAL;
- down(&register_mutex);
+ mutex_lock(&register_mutex);
list_for_each(p, &snd_timer_list) {
timer1 = list_entry(p, struct snd_timer, device_list);
if (timer1->tmr_class > timer->tmr_class)
@@ -857,11 +858,11 @@ static int snd_timer_dev_register(struct snd_device *dev)
if (timer1->tmr_subdevice < timer->tmr_subdevice)
continue;
/* conflicts.. */
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
return -EBUSY;
}
list_add_tail(&timer->device_list, p);
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
return 0;
}
@@ -871,7 +872,7 @@ static int snd_timer_unregister(struct snd_timer *timer)
struct snd_timer_instance *ti;
snd_assert(timer != NULL, return -ENXIO);
- down(&register_mutex);
+ mutex_lock(&register_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) {
@@ -881,7 +882,7 @@ static int snd_timer_unregister(struct snd_timer *timer)
}
}
list_del(&timer->device_list);
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
return snd_timer_free(timer);
}
@@ -1065,7 +1066,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
struct snd_timer_instance *ti;
struct list_head *p, *q;
- down(&register_mutex);
+ mutex_lock(&register_mutex);
list_for_each(p, &snd_timer_list) {
timer = list_entry(p, struct snd_timer, device_list);
switch (timer->tmr_class) {
@@ -1105,7 +1106,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
}
spin_unlock_irqrestore(&timer->lock, flags);
}
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
}
static struct snd_info_entry *snd_timer_proc_entry = NULL;
@@ -1269,7 +1270,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file)
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),
@@ -1325,7 +1326,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
if (copy_from_user(&id, _tid, sizeof(id)))
return -EFAULT;
- down(&register_mutex);
+ mutex_lock(&register_mutex);
if (id.dev_class < 0) { /* first item */
if (list_empty(&snd_timer_list))
snd_timer_user_zero_id(&id);
@@ -1407,7 +1408,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
snd_timer_user_zero_id(&id);
}
}
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
if (copy_to_user(_tid, &id, sizeof(*_tid)))
return -EFAULT;
return 0;
@@ -1432,7 +1433,7 @@ static int snd_timer_user_ginfo(struct file *file,
tid = ginfo->tid;
memset(ginfo, 0, sizeof(*ginfo));
ginfo->tid = tid;
- down(&register_mutex);
+ mutex_lock(&register_mutex);
t = snd_timer_find(&tid);
if (t != NULL) {
ginfo->card = t->card ? t->card->number : -1;
@@ -1451,7 +1452,7 @@ static int snd_timer_user_ginfo(struct file *file,
} else {
err = -ENODEV;
}
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
err = -EFAULT;
kfree(ginfo);
@@ -1467,7 +1468,7 @@ static int snd_timer_user_gparams(struct file *file,
if (copy_from_user(&gparams, _gparams, sizeof(gparams)))
return -EFAULT;
- down(&register_mutex);
+ mutex_lock(&register_mutex);
t = snd_timer_find(&gparams.tid);
if (!t) {
err = -ENODEV;
@@ -1483,7 +1484,7 @@ static int snd_timer_user_gparams(struct file *file,
}
err = t->hw.set_period(t, gparams.period_num, gparams.period_den);
_error:
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
return err;
}
@@ -1500,7 +1501,7 @@ static int snd_timer_user_gstatus(struct file *file,
tid = gstatus.tid;
memset(&gstatus, 0, sizeof(gstatus));
gstatus.tid = tid;
- down(&register_mutex);
+ mutex_lock(&register_mutex);
t = snd_timer_find(&tid);
if (t != NULL) {
if (t->hw.c_resolution)
@@ -1517,7 +1518,7 @@ static int snd_timer_user_gstatus(struct file *file,
} else {
err = -ENODEV;
}
- up(&register_mutex);
+ mutex_unlock(&register_mutex);
if (err >= 0 && copy_to_user(_gstatus, &gstatus, sizeof(gstatus)))
err = -EFAULT;
return err;
@@ -1532,7 +1533,7 @@ static int snd_timer_user_tselect(struct file *file,
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;
@@ -1576,7 +1577,7 @@ static int snd_timer_user_tselect(struct file *file,
}
__err:
- up(&tu->tread_sem);
+ mutex_unlock(&tu->tread_sem);
return err;
}
@@ -1797,17 +1798,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,
{
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: