Commit 910f5d20 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds
Browse files

[PATCH] sem2mutex: sound/oss/



Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 82d4dc5a
......@@ -56,7 +56,8 @@
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include "sound_config.h"
......@@ -79,7 +80,7 @@ static int aci_micpreamp=3; /* microphone preamp-level that can't be *
* checked with ACI versions prior to 0xb0 */
static int mixer_device;
static struct semaphore aci_sem;
static struct mutex aci_mutex;
#ifdef MODULE
static int reset;
......@@ -212,7 +213,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
int write[] = {write1, write2, write3};
int read = -EINTR, i;
if (down_interruptible(&aci_sem))
if (mutex_lock_interruptible(&aci_mutex))
goto out;
for (i=0; i<3; i++) {
......@@ -227,7 +228,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
}
read = aci_rawread();
out_up: up(&aci_sem);
out_up: mutex_unlock(&aci_mutex);
out: return read;
}
......@@ -603,7 +604,7 @@ static int __init attach_aci(void)
char *boardname;
int i, rc = -EBUSY;
init_MUTEX(&aci_sem);
mutex_init(&aci_mutex);
outb(0xE3, 0xf8f); /* Write MAD16 password */
aci_port = (inb(0xf90) & 0x10) ?
......
......@@ -38,6 +38,7 @@
#include <linux/ac97_codec.h>
#include <linux/sound.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <asm/delay.h>
#include <asm/io.h>
......@@ -238,7 +239,7 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
for (i = 0; i < AD_MAX_STATES; i++) {
dev->state[i].card = dev;
init_MUTEX(&dev->state[i].sem);
mutex_init(&dev->state[i].mutex);
init_waitqueue_head(&dev->state[i].dmabuf.wait);
}
......@@ -461,7 +462,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
ssize_t ret = 0;
DECLARE_WAITQUEUE(wait, current);
down(&state->sem);
mutex_lock(&state->mutex);
#if 0
if (dmabuf->mapped) {
ret = -ENXIO;
......@@ -546,7 +547,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
err2:
remove_wait_queue(&state->dmabuf.wait, &wait);
err1:
up(&state->sem);
mutex_unlock(&state->mutex);
return ret;
}
......
......@@ -100,7 +100,7 @@ typedef struct ad1889_state {
unsigned int subdivision;
} dmabuf;
struct semaphore sem;
struct mutex mutex;
} ad1889_state_t;
typedef struct ad1889_dev {
......
......@@ -64,6 +64,8 @@
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#ifndef PCI_DEVICE_ID_ALI_5455
......@@ -234,7 +236,7 @@ struct ali_state {
struct ali_card *card; /* Card info */
/* single open lock mechanism, only used for recording */
struct semaphore open_sem;
struct mutex open_mutex;
wait_queue_head_t open_wait;
/* file mode */
......@@ -2807,7 +2809,7 @@ found_virt:
state->card = card;
state->magic = ALI5455_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
init_MUTEX(&state->open_sem);
mutex_init(&state->open_mutex);
file->private_data = state;
dmabuf->trigger = 0;
/* allocate hardware channels */
......@@ -3359,7 +3361,7 @@ static void __devinit ali_configure_clocking(void)
state->card = card;
state->magic = ALI5455_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
init_MUTEX(&state->open_sem);
mutex_init(&state->open_mutex);
dmabuf->fmt = ALI5455_FMT_STEREO | ALI5455_FMT_16BIT;
dmabuf->trigger = PCM_ENABLE_OUTPUT;
ali_set_dac_rate(state, 48000);
......
......@@ -68,6 +68,8 @@
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/mach-au1x00/au1000.h>
......@@ -120,8 +122,8 @@ struct au1000_state {
int no_vra; // do not use VRA
spinlock_t lock;
struct semaphore open_sem;
struct semaphore sem;
struct mutex open_mutex;
struct mutex sem;
mode_t open_mode;
wait_queue_head_t open_wait;
......@@ -1106,7 +1108,7 @@ static ssize_t au1000_read(struct file *file, char *buffer,
count *= db->cnt_factor;
down(&s->sem);
mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
......@@ -1125,14 +1127,14 @@ static ssize_t au1000_read(struct file *file, char *buffer,
ret = -EAGAIN;
goto out;
}
up(&s->sem);
mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
down(&s->sem);
mutex_lock(&s->sem);
}
} while (avail <= 0);
......@@ -1159,7 +1161,7 @@ static ssize_t au1000_read(struct file *file, char *buffer,
} // while (count > 0)
out:
up(&s->sem);
mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
......@@ -1187,7 +1189,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
count *= db->cnt_factor;
down(&s->sem);
mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
......@@ -1204,14 +1206,14 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
ret = -EAGAIN;
goto out;
}
up(&s->sem);
mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
down(&s->sem);
mutex_lock(&s->sem);
}
} while (avail <= 0);
......@@ -1240,7 +1242,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
} // while (count > 0)
out:
up(&s->sem);
mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
......@@ -1298,7 +1300,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
dbg("%s", __FUNCTION__);
lock_kernel();
down(&s->sem);
mutex_lock(&s->sem);
if (vma->vm_flags & VM_WRITE)
db = &s->dma_dac;
else if (vma->vm_flags & VM_READ)
......@@ -1324,7 +1326,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_flags &= ~VM_IO;
db->mapped = 1;
out:
up(&s->sem);
mutex_unlock(&s->sem);
unlock_kernel();
return ret;
}
......@@ -1829,21 +1831,21 @@ static int au1000_open(struct inode *inode, struct file *file)
file->private_data = s;
/* wait for device to become free */
down(&s->open_sem);
mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
down(&s->open_sem);
mutex_lock(&s->open_mutex);
}
stop_dac(s);
......@@ -1879,8 +1881,8 @@ static int au1000_open(struct inode *inode, struct file *file)
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
up(&s->open_sem);
init_MUTEX(&s->sem);
mutex_unlock(&s->open_mutex);
mutex_init(&s->sem);
return nonseekable_open(inode, file);
}
......@@ -1896,7 +1898,7 @@ static int au1000_release(struct inode *inode, struct file *file)
lock_kernel();
}
down(&s->open_sem);
mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
......@@ -1906,7 +1908,7 @@ static int au1000_release(struct inode *inode, struct file *file)
dealloc_dmabuf(s, &s->dma_adc);
}
s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
......@@ -1996,7 +1998,7 @@ static int __devinit au1000_probe(void)
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
init_MUTEX(&s->open_sem);
mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->codec.private_data = s;
s->codec.id = 0;
......
......@@ -52,6 +52,8 @@
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
......@@ -90,8 +92,8 @@ static struct au1550_state {
int no_vra; /* do not use VRA */
spinlock_t lock;
struct semaphore open_sem;
struct semaphore sem;
struct mutex open_mutex;
struct mutex sem;
mode_t open_mode;
wait_queue_head_t open_wait;
......@@ -1044,7 +1046,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
count *= db->cnt_factor;
down(&s->sem);
mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
......@@ -1064,14 +1066,14 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
ret = -EAGAIN;
goto out;
}
up(&s->sem);
mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
down(&s->sem);
mutex_lock(&s->sem);
}
} while (avail <= 0);
......@@ -1099,7 +1101,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
} /* while (count > 0) */
out:
up(&s->sem);
mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
......@@ -1125,7 +1127,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
count *= db->cnt_factor;
down(&s->sem);
mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
......@@ -1143,14 +1145,14 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
ret = -EAGAIN;
goto out;
}
up(&s->sem);
mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
down(&s->sem);
mutex_lock(&s->sem);
}
} while (avail <= 0);
......@@ -1196,7 +1198,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
} /* while (count > 0) */
out:
up(&s->sem);
mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
......@@ -1253,7 +1255,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
int ret = 0;
lock_kernel();
down(&s->sem);
mutex_lock(&s->sem);
if (vma->vm_flags & VM_WRITE)
db = &s->dma_dac;
else if (vma->vm_flags & VM_READ)
......@@ -1279,7 +1281,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_flags &= ~VM_IO;
db->mapped = 1;
out:
up(&s->sem);
mutex_unlock(&s->sem);
unlock_kernel();
return ret;
}
......@@ -1790,21 +1792,21 @@ au1550_open(struct inode *inode, struct file *file)
file->private_data = s;
/* wait for device to become free */
down(&s->open_sem);
mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
down(&s->open_sem);
mutex_lock(&s->open_mutex);
}
stop_dac(s);
......@@ -1840,8 +1842,8 @@ au1550_open(struct inode *inode, struct file *file)
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
up(&s->open_sem);
init_MUTEX(&s->sem);
mutex_unlock(&s->open_mutex);
mutex_init(&s->sem);
return 0;
}
......@@ -1858,7 +1860,7 @@ au1550_release(struct inode *inode, struct file *file)
lock_kernel();
}
down(&s->open_sem);
mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
kfree(s->dma_dac.rawbuf);
......@@ -1870,7 +1872,7 @@ au1550_release(struct inode *inode, struct file *file)
s->dma_adc.rawbuf = NULL;
}
s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
......@@ -1902,7 +1904,7 @@ au1550_probe(void)
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
init_MUTEX(&s->open_sem);
mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->codec = ac97_alloc_codec();
......
......@@ -32,6 +32,8 @@
#include <linux/soundcard.h>
#include <linux/slab.h>
#include <linux/kdev_t.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/io.h>
......@@ -108,7 +110,7 @@ struct btaudio {
/* locking */
int users;
struct semaphore lock;
struct mutex lock;
/* risc instructions */
unsigned int risc_size;
......@@ -440,7 +442,7 @@ static struct file_operations btaudio_mixer_fops = {
static int btaudio_dsp_open(struct inode *inode, struct file *file,
struct btaudio *bta, int analog)
{
down(&bta->lock);
mutex_lock(&bta->lock);
if (bta->users)
goto busy;
bta->users++;
......@@ -452,11 +454,11 @@ static int btaudio_dsp_open(struct inode *inode, struct file *file,
bta->read_count = 0;
bta->sampleshift = 0;
up(&bta->lock);
mutex_unlock(&bta->lock);
return 0;
busy:
up(&bta->lock);
mutex_unlock(&bta->lock);
return -EBUSY;
}
......@@ -496,11 +498,11 @@ static int btaudio_dsp_release(struct inode *inode, struct file *file)
{
struct btaudio *bta = file->private_data;
down(&bta->lock);
mutex_lock(&bta->lock);
if (bta->recording)
stop_recording(bta);
bta->users--;
up(&bta->lock);
mutex_unlock(&bta->lock);
return 0;
}
......@@ -513,7 +515,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
DECLARE_WAITQUEUE(wait, current);
add_wait_queue(&bta->readq, &wait);
down(&bta->lock);
mutex_lock(&bta->lock);
while (swcount > 0) {
if (0 == bta->read_count) {
if (!bta->recording) {
......@@ -528,10 +530,10 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
ret = -EAGAIN;
break;
}
up(&bta->lock);
mutex_unlock(&bta->lock);
current->state = TASK_INTERRUPTIBLE;
schedule();
down(&bta->lock);
mutex_lock(&bta->lock);
if(signal_pending(current)) {
if (0 == ret)
ret = -EINTR;
......@@ -604,7 +606,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
if (bta->read_offset == bta->buf_size)
bta->read_offset = 0;
}
up(&bta->lock);
mutex_unlock(&bta->lock);
remove_wait_queue(&bta->readq, &wait);
current->state = TASK_RUNNING;
return ret;
......@@ -651,10 +653,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
bta->decimation = 0;
}
if (bta->recording) {
down(&bta->lock);
mutex_lock(&bta->lock);
stop_recording(bta);
start_recording(bta);
up(&bta->lock);
mutex_unlock(&bta->lock);
}
/* fall through */
case SOUND_PCM_READ_RATE:
......@@ -716,10 +718,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
else
bta->bits = 16;
if (bta->recording) {
down(&bta->lock);
mutex_lock(&bta->lock);
stop_recording(bta);
start_recording(bta);
up(&bta->lock);
mutex_unlock(&bta->lock);
}
}
if (debug)
......@@ -736,9 +738,9 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
case SNDCTL_DSP_RESET:
if (bta->recording) {
down(&bta->lock);
mutex_lock(&bta->lock);
stop_recording(bta);
up(&bta->lock);
mutex_unlock(&bta->lock);
}
return 0;
case SNDCTL_DSP_GETBLKSIZE:
......@@ -941,7 +943,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
if (rate)
bta->rate = rate;
init_MUTEX(&bta->lock);
mutex_init(&bta->lock);
init_waitqueue_head(&bta->readq);
if (-1 != latency) {
......
......@@ -138,6 +138,8 @@
#endif
#ifdef CONFIG_SOUND_CMPCI_JOYSTICK
#include <linux/gameport.h>
#include <linux/mutex.h>
#endif
/* --------------------------------------------------------------------- */
......@@ -392,7 +394,7 @@ struct cm_state {
unsigned char fmt, enable;
spinlock_t lock;
struct semaphore open_sem;
struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
......@@ -2825,21 +2827,21 @@ static int cm_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
down(&s->open_sem);
mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
up(&s->open_sem);
mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
down(&s->open_sem);
mutex_lock(&s->open_mutex);
}
if (file->f_mode & FMODE_READ) {
s->status &= ~DO_BIGENDIAN_R;
......@@ -2867,7 +2869,7 @@ static int cm_open(struct inode *inode, struct file *file)
}
set_fmt(s, fmtm, fmts);