Commit f82945df authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] oss: semaphore to mutex conversion

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Extracted for OSS/Free changes from Ingo's original patches.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6389a385
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/ac97_codec.h> #include <linux/ac97_codec.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#define CODEC_ID_BUFSZ 14 #define CODEC_ID_BUFSZ 14
...@@ -304,7 +304,7 @@ static const unsigned int ac97_oss_rm[] = { ...@@ -304,7 +304,7 @@ static const unsigned int ac97_oss_rm[] = {
static LIST_HEAD(codecs); static LIST_HEAD(codecs);
static LIST_HEAD(codec_drivers); static LIST_HEAD(codec_drivers);
static DECLARE_MUTEX(codec_sem); static DEFINE_MUTEX(codec_mutex);
/* reads the given OSS mixer from the ac97 the caller must have insured that the ac97 knows /* reads the given OSS mixer from the ac97 the caller must have insured that the ac97 knows
about that given mixer, and should be holding a spinlock for the card */ about that given mixer, and should be holding a spinlock for the card */
...@@ -769,9 +769,9 @@ void ac97_release_codec(struct ac97_codec *codec) ...@@ -769,9 +769,9 @@ void ac97_release_codec(struct ac97_codec *codec)
{ {
/* Remove from the list first, we don't want to be /* Remove from the list first, we don't want to be
"rediscovered" */ "rediscovered" */
down(&codec_sem); mutex_lock(&codec_mutex);
list_del(&codec->list); list_del(&codec->list);
up(&codec_sem); mutex_unlock(&codec_mutex);
/* /*
* The driver needs to deal with internal * The driver needs to deal with internal
* locking to avoid accidents here. * locking to avoid accidents here.
...@@ -889,7 +889,7 @@ int ac97_probe_codec(struct ac97_codec *codec) ...@@ -889,7 +889,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
* callbacks. * callbacks.
*/ */
down(&codec_sem); mutex_lock(&codec_mutex);
list_add(&codec->list, &codecs); list_add(&codec->list, &codecs);
list_for_each(l, &codec_drivers) { list_for_each(l, &codec_drivers) {
...@@ -903,7 +903,7 @@ int ac97_probe_codec(struct ac97_codec *codec) ...@@ -903,7 +903,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
} }
} }
up(&codec_sem); mutex_unlock(&codec_mutex);
return 1; return 1;
} }
...@@ -1439,7 +1439,7 @@ int ac97_register_driver(struct ac97_driver *driver) ...@@ -1439,7 +1439,7 @@ int ac97_register_driver(struct ac97_driver *driver)
struct list_head *l; struct list_head *l;
struct ac97_codec *c; struct ac97_codec *c;
down(&codec_sem); mutex_lock(&codec_mutex);
INIT_LIST_HEAD(&driver->list); INIT_LIST_HEAD(&driver->list);
list_add(&driver->list, &codec_drivers); list_add(&driver->list, &codec_drivers);
...@@ -1452,7 +1452,7 @@ int ac97_register_driver(struct ac97_driver *driver) ...@@ -1452,7 +1452,7 @@ int ac97_register_driver(struct ac97_driver *driver)
continue; continue;
c->driver = driver; c->driver = driver;
} }
up(&codec_sem); mutex_unlock(&codec_mutex);
return 0; return 0;
} }
...@@ -1471,7 +1471,7 @@ void ac97_unregister_driver(struct ac97_driver *driver) ...@@ -1471,7 +1471,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
struct list_head *l; struct list_head *l;
struct ac97_codec *c; struct ac97_codec *c;
down(&codec_sem); mutex_lock(&codec_mutex);
list_del_init(&driver->list); list_del_init(&driver->list);
list_for_each(l, &codecs) list_for_each(l, &codecs)
...@@ -1483,7 +1483,7 @@ void ac97_unregister_driver(struct ac97_driver *driver) ...@@ -1483,7 +1483,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
} }
} }
up(&codec_sem); mutex_unlock(&codec_mutex);
} }
EXPORT_SYMBOL_GPL(ac97_unregister_driver); EXPORT_SYMBOL_GPL(ac97_unregister_driver);
...@@ -1494,14 +1494,14 @@ static int swap_headphone(int remove_master) ...@@ -1494,14 +1494,14 @@ static int swap_headphone(int remove_master)
struct ac97_codec *c; struct ac97_codec *c;
if (remove_master) { if (remove_master) {
down(&codec_sem); mutex_lock(&codec_mutex);
list_for_each(l, &codecs) list_for_each(l, &codecs)
{ {
c = list_entry(l, struct ac97_codec, list); c = list_entry(l, struct ac97_codec, list);
if (supported_mixer(c, SOUND_MIXER_PHONEOUT)) if (supported_mixer(c, SOUND_MIXER_PHONEOUT))
c->supported_mixers &= ~SOUND_MASK_PHONEOUT; c->supported_mixers &= ~SOUND_MASK_PHONEOUT;
} }
up(&codec_sem); mutex_unlock(&codec_mutex);
} else } else
ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO; ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO;
......
...@@ -245,9 +245,9 @@ struct cs4281_state { ...@@ -245,9 +245,9 @@ struct cs4281_state {
void *tmpbuff; // tmp buffer for sample conversions void *tmpbuff; // tmp buffer for sample conversions
unsigned ena; unsigned ena;
spinlock_t lock; spinlock_t lock;
struct semaphore open_sem; struct mutex open_sem;
struct semaphore open_sem_adc; struct mutex open_sem_adc;
struct semaphore open_sem_dac; struct mutex open_sem_dac;
mode_t open_mode; mode_t open_mode;
wait_queue_head_t open_wait; wait_queue_head_t open_wait;
wait_queue_head_t open_wait_adc; wait_queue_head_t open_wait_adc;
...@@ -3598,20 +3598,20 @@ static int cs4281_release(struct inode *inode, struct file *file) ...@@ -3598,20 +3598,20 @@ static int cs4281_release(struct inode *inode, struct file *file)
if (file->f_mode & FMODE_WRITE) { if (file->f_mode & FMODE_WRITE) {
drain_dac(s, file->f_flags & O_NONBLOCK); drain_dac(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem_dac); mutex_lock(&s->open_sem_dac);
stop_dac(s); stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac); dealloc_dmabuf(s, &s->dma_dac);
s->open_mode &= ~FMODE_WRITE; s->open_mode &= ~FMODE_WRITE;
up(&s->open_sem_dac); mutex_unlock(&s->open_sem_dac);
wake_up(&s->open_wait_dac); wake_up(&s->open_wait_dac);
} }
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
drain_adc(s, file->f_flags & O_NONBLOCK); drain_adc(s, file->f_flags & O_NONBLOCK);
down(&s->open_sem_adc); mutex_lock(&s->open_sem_adc);
stop_adc(s); stop_adc(s);
dealloc_dmabuf(s, &s->dma_adc); dealloc_dmabuf(s, &s->dma_adc);
s->open_mode &= ~FMODE_READ; s->open_mode &= ~FMODE_READ;
up(&s->open_sem_adc); mutex_unlock(&s->open_sem_adc);
wake_up(&s->open_wait_adc); wake_up(&s->open_wait_adc);
} }
return 0; return 0;
...@@ -3651,33 +3651,33 @@ static int cs4281_open(struct inode *inode, struct file *file) ...@@ -3651,33 +3651,33 @@ static int cs4281_open(struct inode *inode, struct file *file)
return -ENODEV; return -ENODEV;
} }
if (file->f_mode & FMODE_WRITE) { if (file->f_mode & FMODE_WRITE) {
down(&s->open_sem_dac); mutex_lock(&s->open_sem_dac);
while (s->open_mode & FMODE_WRITE) { while (s->open_mode & FMODE_WRITE) {
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
up(&s->open_sem_dac); mutex_unlock(&s->open_sem_dac);
return -EBUSY; return -EBUSY;
} }
up(&s->open_sem_dac); mutex_unlock(&s->open_sem_dac);
interruptible_sleep_on(&s->open_wait_dac); interruptible_sleep_on(&s->open_wait_dac);
if (signal_pending(current)) if (signal_pending(current))
return -ERESTARTSYS; return -ERESTARTSYS;
down(&s->open_sem_dac); mutex_lock(&s->open_sem_dac);
} }
} }
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
down(&s->open_sem_adc); mutex_lock(&s->open_sem_adc);
while (s->open_mode & FMODE_READ) { while (s->open_mode & FMODE_READ) {
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
up(&s->open_sem_adc); mutex_unlock(&s->open_sem_adc);
return -EBUSY; return -EBUSY;
} }
up(&s->open_sem_adc); mutex_unlock(&s->open_sem_adc);
interruptible_sleep_on(&s->open_wait_adc); interruptible_sleep_on(&s->open_wait_adc);
if (signal_pending(current)) if (signal_pending(current))
return -ERESTARTSYS; return -ERESTARTSYS;
down(&s->open_sem_adc); mutex_lock(&s->open_sem_adc);
} }
} }
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
...@@ -3691,7 +3691,7 @@ static int cs4281_open(struct inode *inode, struct file *file) ...@@ -3691,7 +3691,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
s->ena &= ~FMODE_READ; s->ena &= ~FMODE_READ;
s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
s->dma_adc.subdivision = 0; s->dma_adc.subdivision = 0;
up(&s->open_sem_adc); mutex_unlock(&s->open_sem_adc);
if (prog_dmabuf_adc(s)) { if (prog_dmabuf_adc(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
...@@ -3711,7 +3711,7 @@ static int cs4281_open(struct inode *inode, struct file *file) ...@@ -3711,7 +3711,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
s->ena &= ~FMODE_WRITE; s->ena &= ~FMODE_WRITE;
s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
s->dma_dac.subdivision = 0; s->dma_dac.subdivision = 0;
up(&s->open_sem_dac); mutex_unlock(&s->open_sem_dac);
if (prog_dmabuf_dac(s)) { if (prog_dmabuf_dac(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
...@@ -3978,17 +3978,17 @@ static int cs4281_midi_open(struct inode *inode, struct file *file) ...@@ -3978,17 +3978,17 @@ static int cs4281_midi_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s); VALIDATE_STATE(s);
file->private_data = s; file->private_data = s;
// wait for device to become free // wait for device to become free
down(&s->open_sem); mutex_lock(&s->open_sem);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
up(&s->open_sem); mutex_unlock(&s->open_sem);
return -EBUSY; return -EBUSY;
} }
up(&s->open_sem); mutex_unlock(&s->open_sem);
interruptible_sleep_on(&s->open_wait); interruptible_sleep_on(&s->open_wait);
if (signal_pending(current)) if (signal_pending(current))
return -ERESTARTSYS; return -ERESTARTSYS;
down(&s->open_sem); mutex_lock(&s->open_sem);
} }
spin_lock_irqsave(&s->lock, flags); spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) { if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
...@@ -4018,7 +4018,7 @@ static int cs4281_midi_open(struct inode *inode, struct file *file) ...@@ -4018,7 +4018,7 @@ static int cs4281_midi_open(struct inode *inode, struct file *file)
(file-> (file->
f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ |
FMODE_MIDI_WRITE); FMODE_MIDI_WRITE);
up(&s->open_sem); mutex_unlock(&s->open_sem);
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
} }
...@@ -4057,7 +4057,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file) ...@@ -4057,7 +4057,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&s->midi.owait, &wait); remove_wait_queue(&s->midi.owait, &wait);
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
} }
down(&s->open_sem); mutex_lock(&s->open_sem);
s->open_mode &= s->open_mode &=
(~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ | (~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ |
FMODE_MIDI_WRITE); FMODE_MIDI_WRITE);
...@@ -4067,7 +4067,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file) ...@@ -4067,7 +4067,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
del_timer(&s->midi.timer); del_timer(&s->midi.timer);
} }
spin_unlock_irqrestore(&s->lock, flags); spin_unlock_irqrestore(&s->lock, flags);
up(&s->open_sem); mutex_unlock(&s->open_sem);
wake_up(&s->open_wait); wake_up(&s->open_wait);
return 0; return 0;
} }
...@@ -4300,9 +4300,9 @@ static int __devinit cs4281_probe(struct pci_dev *pcidev, ...@@ -4300,9 +4300,9 @@ static int __devinit cs4281_probe(struct pci_dev *pcidev,
init_waitqueue_head(&s->open_wait_dac); init_waitqueue_head(&s->open_wait_dac);
init_waitqueue_head(&s->midi.iwait); init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait); init_waitqueue_head(&s->midi.owait);
init_MUTEX(&s->open_sem); mutex_init(&s->open_sem);
init_MUTEX(&s->open_sem_adc); mutex_init(&s->open_sem_adc);
init_MUTEX(&s->open_sem_dac); mutex_init(&s->open_sem_dac);
spin_lock_init(&s->lock); spin_lock_init(&s->lock);
s->pBA0phys = pci_resource_start(pcidev, 0); s->pBA0phys = pci_resource_start(pcidev, 0);
s->pBA1phys = pci_resource_start(pcidev, 1); s->pBA1phys = pci_resource_start(pcidev, 1);
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/input.h> #include <linux/input.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#ifdef CONFIG_ADB_CUDA #ifdef CONFIG_ADB_CUDA
#include <linux/cuda.h> #include <linux/cuda.h>
#endif #endif
...@@ -130,7 +130,7 @@ static struct resource awacs_rsrc[3]; ...@@ -130,7 +130,7 @@ static struct resource awacs_rsrc[3];
static char awacs_name[64]; static char awacs_name[64];
static int awacs_revision; static int awacs_revision;
static int awacs_sleeping; static int awacs_sleeping;
static DECLARE_MUTEX(dmasound_sem); static DEFINE_MUTEX(dmasound_mutex);
static int sound_device_id; /* exists after iMac revA */ static int sound_device_id; /* exists after iMac revA */
static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */ static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */
...@@ -312,11 +312,11 @@ extern int daca_enter_sleep(void); ...@@ -312,11 +312,11 @@ extern int daca_enter_sleep(void);
extern int daca_leave_sleep(void); extern int daca_leave_sleep(void);
#define TRY_LOCK() \ #define TRY_LOCK() \
if ((rc = down_interruptible(&dmasound_sem)) != 0) \ if ((rc = mutex_lock_interruptible(&dmasound_mutex)) != 0) \
return rc; return rc;
#define LOCK() down(&dmasound_sem); #define LOCK() mutex_lock(&dmasound_mutex);
#define UNLOCK() up(&dmasound_sem); #define UNLOCK() mutex_unlock(&dmasound_mutex);
/* We use different versions that the ones provided in dmasound.h /* We use different versions that the ones provided in dmasound.h
* *
......
...@@ -181,7 +181,7 @@ struct emu10k1_card ...@@ -181,7 +181,7 @@ struct emu10k1_card
struct emu10k1_mpuout *mpuout; struct emu10k1_mpuout *mpuout;
struct emu10k1_mpuin *mpuin; struct emu10k1_mpuin *mpuin;
struct semaphore open_sem; struct mutex open_sem;
mode_t open_mode; mode_t open_mode;
wait_queue_head_t open_wait; wait_queue_head_t open_wait;
......
...@@ -1320,7 +1320,7 @@ static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_dev ...@@ -1320,7 +1320,7 @@ static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_dev
card->is_aps = (subsysvid == EMU_APS_SUBID); card->is_aps = (subsysvid == EMU_APS_SUBID);
spin_lock_init(&card->lock); spin_lock_init(&card->lock);
init_MUTEX(&card->open_sem); mutex_init(&card->open_sem);
card->open_mode = 0; card->open_mode = 0;
init_waitqueue_head(&card->open_wait); init_waitqueue_head(&card->open_wait);
......
...@@ -110,21 +110,21 @@ static int emu10k1_midi_open(struct inode *inode, struct file *file) ...@@ -110,21 +110,21 @@ static int emu10k1_midi_open(struct inode *inode, struct file *file)
#endif #endif
/* Wait for device to become free */ /* Wait for device to become free */
down(&card->open_sem); mutex_lock(&card->open_sem);
while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) { while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
up(&card->open_sem); mutex_unlock(&card->open_sem);
return -EBUSY; return -EBUSY;
} }
up(&card->open_sem); mutex_unlock(&card->open_sem);
interruptible_sleep_on(&card->open_wait); interruptible_sleep_on(&card->open_wait);
if (signal_pending(current)) { if (signal_pending(current)) {
return -ERESTARTSYS; return -ERESTARTSYS;
} }
down(&card->open_sem); mutex_lock(&card->open_sem);
} }
if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL) if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
...@@ -183,7 +183,7 @@ static int emu10k1_midi_open(struct inode *inode, struct file *file) ...@@ -183,7 +183,7 @@ static int emu10k1_midi_open(struct inode *inode, struct file *file)
card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE); card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
up(&card->open_sem); mutex_unlock(&card->open_sem);
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
} }
...@@ -234,9 +234,9 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file) ...@@ -234,9 +234,9 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file)
kfree(midi_dev); kfree(midi_dev);
down(&card->open_sem); mutex_lock(&card->open_sem);
card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE)); card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE));
up(&card->open_sem); mutex_unlock(&card->open_sem);
wake_up_interruptible(&card->open_wait); wake_up_interruptible(&card->open_wait);
unlock_kernel(); unlock_kernel();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment