diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-03-23 03:00:39 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 07:38:13 -0800 |
commit | 910f5d202ce39cc78de1bbb679285a3167de9fb2 (patch) | |
tree | 2c5b55c2b141aaf016c459beb397fc702c41b967 /sound/oss/cs46xx.c | |
parent | 82d4dc5adb0055393248ad4ab8de392fac708a12 (diff) | |
download | linux-910f5d202ce39cc78de1bbb679285a3167de9fb2.tar.gz linux-910f5d202ce39cc78de1bbb679285a3167de9fb2.tar.bz2 linux-910f5d202ce39cc78de1bbb679285a3167de9fb2.zip |
[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: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sound/oss/cs46xx.c')
-rw-r--r-- | sound/oss/cs46xx.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c index 58e25c82eaf2..53881bc91bba 100644 --- a/sound/oss/cs46xx.c +++ b/sound/oss/cs46xx.c @@ -90,6 +90,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/ac97_codec.h> +#include <linux/mutex.h> #include <asm/io.h> #include <asm/dma.h> @@ -238,7 +239,7 @@ struct cs_state { struct cs_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 */ @@ -297,7 +298,7 @@ struct cs_state { unsigned subdivision; } dmabuf; /* Guard against mmap/write/read races */ - struct semaphore sem; + struct mutex sem; }; struct cs_card { @@ -375,7 +376,7 @@ struct cs_card { unsigned char ibuf[CS_MIDIINBUF]; unsigned char obuf[CS_MIDIOUTBUF]; mode_t open_mode; - struct semaphore open_sem; + struct mutex open_mutex; } midi; struct cs46xx_pm pm; }; @@ -1428,9 +1429,9 @@ static int prog_dmabuf(struct cs_state *state) { int ret; - down(&state->sem); + mutex_lock(&state->sem); ret = __prog_dmabuf(state); - up(&state->sem); + mutex_unlock(&state->sem); return ret; } @@ -1831,17 +1832,17 @@ static int cs_midi_open(struct inode *inode, struct file *file) file->private_data = card; /* wait for device to become free */ - down(&card->midi.open_sem); + mutex_lock(&card->midi.open_mutex); while (card->midi.open_mode & file->f_mode) { if (file->f_flags & O_NONBLOCK) { - up(&card->midi.open_sem); + mutex_unlock(&card->midi.open_mutex); return -EBUSY; } - up(&card->midi.open_sem); + mutex_unlock(&card->midi.open_mutex); interruptible_sleep_on(&card->midi.open_wait); if (signal_pending(current)) return -ERESTARTSYS; - down(&card->midi.open_sem); + mutex_lock(&card->midi.open_mutex); } spin_lock_irqsave(&card->midi.lock, flags); if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) { @@ -1859,7 +1860,7 @@ static int cs_midi_open(struct inode *inode, struct file *file) } spin_unlock_irqrestore(&card->midi.lock, flags); card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); - up(&card->midi.open_sem); + mutex_unlock(&card->midi.open_mutex); return 0; } @@ -1891,9 +1892,9 @@ static int cs_midi_release(struct inode *inode, struct file *file) remove_wait_queue(&card->midi.owait, &wait); current->state = TASK_RUNNING; } - down(&card->midi.open_sem); + mutex_lock(&card->midi.open_mutex); card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE))); - up(&card->midi.open_sem); + mutex_unlock(&card->midi.open_mutex); wake_up(&card->midi.open_wait); return 0; } @@ -2081,7 +2082,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof if (!access_ok(VERIFY_WRITE, buffer, count)) return -EFAULT; - down(&state->sem); + mutex_lock(&state->sem); if (!dmabuf->ready && (ret = __prog_dmabuf(state))) goto out2; @@ -2114,13 +2115,13 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof if (!ret) ret = -EAGAIN; goto out; } - up(&state->sem); + mutex_unlock(&state->sem); schedule(); if (signal_pending(current)) { if(!ret) ret = -ERESTARTSYS; goto out; } - down(&state->sem); + mutex_lock(&state->sem); if (dmabuf->mapped) { if(!ret) @@ -2155,7 +2156,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof out: remove_wait_queue(&state->dmabuf.wait, &wait); out2: - up(&state->sem); + mutex_unlock(&state->sem); set_current_state(TASK_RUNNING); CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4, printk("cs46xx: cs_read()- %zd\n",ret) ); @@ -2184,7 +2185,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou return -EFAULT; dmabuf = &state->dmabuf; - down(&state->sem); + mutex_lock(&state->sem); if (dmabuf->mapped) { ret = -ENXIO; @@ -2240,13 +2241,13 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou if (!ret) ret = -EAGAIN; goto out; } - up(&state->sem); + mutex_unlock(&state->sem); schedule(); if (signal_pending(current)) { if(!ret) ret = -ERESTARTSYS; goto out; } - down(&state->sem); + mutex_lock(&state->sem); if (dmabuf->mapped) { if(!ret) @@ -2278,7 +2279,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou start_dac(state); } out: - up(&state->sem); + mutex_unlock(&state->sem); remove_wait_queue(&state->dmabuf.wait, &wait); set_current_state(TASK_RUNNING); @@ -2411,7 +2412,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma) goto out; } - down(&state->sem); + mutex_lock(&state->sem); dmabuf = &state->dmabuf; if (cs4x_pgoff(vma) != 0) { @@ -2438,7 +2439,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma) CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") ); out: - up(&state->sem); + mutex_unlock(&state->sem); return ret; } @@ -3200,7 +3201,7 @@ static int cs_open(struct inode *inode, struct file *file) if (state == NULL) return -ENOMEM; memset(state, 0, sizeof(struct cs_state)); - init_MUTEX(&state->sem); + mutex_init(&state->sem); dmabuf = &state->dmabuf; dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if(dmabuf->pbuf==NULL) @@ -3241,10 +3242,10 @@ static int cs_open(struct inode *inode, struct file *file) state->virt = 0; state->magic = CS_STATE_MAGIC; init_waitqueue_head(&dmabuf->wait); - init_MUTEX(&state->open_sem); + mutex_init(&state->open_mutex); file->private_data = card; - down(&state->open_sem); + mutex_lock(&state->open_mutex); /* set default sample format. According to OSS Programmer's Guide /dev/dsp should be default to unsigned 8-bits, mono, with sample rate 8kHz and @@ -3260,7 +3261,7 @@ static int cs_open(struct inode *inode, struct file *file) cs_set_divisor(dmabuf); state->open_mode |= FMODE_READ; - up(&state->open_sem); + mutex_unlock(&state->open_mutex); } if(file->f_mode & FMODE_WRITE) { @@ -3271,7 +3272,7 @@ static int cs_open(struct inode *inode, struct file *file) if (state == NULL) return -ENOMEM; memset(state, 0, sizeof(struct cs_state)); - init_MUTEX(&state->sem); + mutex_init(&state->sem); dmabuf = &state->dmabuf; dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if(dmabuf->pbuf==NULL) @@ -3312,10 +3313,10 @@ static int cs_open(struct inode *inode, struct file *file) state->virt = 1; state->magic = CS_STATE_MAGIC; init_waitqueue_head(&dmabuf->wait); - init_MUTEX(&state->open_sem); + mutex_init(&state->open_mutex); file->private_data = card; - down(&state->open_sem); + mutex_lock(&state->open_mutex); /* set default sample format. According to OSS Programmer's Guide /dev/dsp should be default to unsigned 8-bits, mono, with sample rate 8kHz and @@ -3331,7 +3332,7 @@ static int cs_open(struct inode *inode, struct file *file) cs_set_divisor(dmabuf); state->open_mode |= FMODE_WRITE; - up(&state->open_sem); + mutex_unlock(&state->open_mutex); if((ret = prog_dmabuf(state))) return ret; } @@ -3363,14 +3364,14 @@ static int cs_release(struct inode *inode, struct file *file) cs_clear_tail(state); drain_dac(state, file->f_flags & O_NONBLOCK); /* stop DMA state machine and free DMA buffers/channels */ - down(&state->open_sem); + mutex_lock(&state->open_mutex); stop_dac(state); dealloc_dmabuf(state); state->card->free_pcm_channel(state->card, dmabuf->channel->num); free_page((unsigned long)state->dmabuf.pbuf); - /* we're covered by the open_sem */ - up(&state->open_sem); + /* we're covered by the open_mutex */ + mutex_unlock(&state->open_mutex); state->card->states[state->virt] = NULL; state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); @@ -3395,14 +3396,14 @@ static int cs_release(struct inode *inode, struct file *file) { CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n") ); dmabuf = &state->dmabuf; - down(&state->open_sem); + mutex_lock(&state->open_mutex); stop_adc(state); dealloc_dmabuf(state); state->card->free_pcm_channel(state->card, dmabuf->channel->num); free_page((unsigned long)state->dmabuf.pbuf); - /* we're covered by the open_sem */ - up(&state->open_sem); + /* we're covered by the open_mutex */ + mutex_unlock(&state->open_mutex); state->card->states[state->virt] = NULL; state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); @@ -5507,7 +5508,7 @@ static int __devinit cs46xx_probe(struct pci_dev *pci_dev, } init_waitqueue_head(&card->midi.open_wait); - init_MUTEX(&card->midi.open_sem); + mutex_init(&card->midi.open_mutex); init_waitqueue_head(&card->midi.iwait); init_waitqueue_head(&card->midi.owait); cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST); |