mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
[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: Ingo Molnar <mingo@elte.hu> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
6389a38511
commit
f82945dff5
@ -55,7 +55,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include <linux/ac97_codec.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/semaphore.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#define CODEC_ID_BUFSZ 14
|
||||
|
||||
@ -304,7 +304,7 @@ static const unsigned int ac97_oss_rm[] = {
|
||||
|
||||
static LIST_HEAD(codecs);
|
||||
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
|
||||
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)
|
||||
{
|
||||
/* Remove from the list first, we don't want to be
|
||||
"rediscovered" */
|
||||
down(&codec_sem);
|
||||
mutex_lock(&codec_mutex);
|
||||
list_del(&codec->list);
|
||||
up(&codec_sem);
|
||||
mutex_unlock(&codec_mutex);
|
||||
/*
|
||||
* The driver needs to deal with internal
|
||||
* locking to avoid accidents here.
|
||||
@ -889,7 +889,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
|
||||
* callbacks.
|
||||
*/
|
||||
|
||||
down(&codec_sem);
|
||||
mutex_lock(&codec_mutex);
|
||||
list_add(&codec->list, &codecs);
|
||||
|
||||
list_for_each(l, &codec_drivers) {
|
||||
@ -903,7 +903,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
|
||||
}
|
||||
}
|
||||
|
||||
up(&codec_sem);
|
||||
mutex_unlock(&codec_mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1439,7 +1439,7 @@ int ac97_register_driver(struct ac97_driver *driver)
|
||||
struct list_head *l;
|
||||
struct ac97_codec *c;
|
||||
|
||||
down(&codec_sem);
|
||||
mutex_lock(&codec_mutex);
|
||||
INIT_LIST_HEAD(&driver->list);
|
||||
list_add(&driver->list, &codec_drivers);
|
||||
|
||||
@ -1452,7 +1452,7 @@ int ac97_register_driver(struct ac97_driver *driver)
|
||||
continue;
|
||||
c->driver = driver;
|
||||
}
|
||||
up(&codec_sem);
|
||||
mutex_unlock(&codec_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1471,7 +1471,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
|
||||
struct list_head *l;
|
||||
struct ac97_codec *c;
|
||||
|
||||
down(&codec_sem);
|
||||
mutex_lock(&codec_mutex);
|
||||
list_del_init(&driver->list);
|
||||
|
||||
list_for_each(l, &codecs)
|
||||
@ -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);
|
||||
@ -1494,14 +1494,14 @@ static int swap_headphone(int remove_master)
|
||||
struct ac97_codec *c;
|
||||
|
||||
if (remove_master) {
|
||||
down(&codec_sem);
|
||||
mutex_lock(&codec_mutex);
|
||||
list_for_each(l, &codecs)
|
||||
{
|
||||
c = list_entry(l, struct ac97_codec, list);
|
||||
if (supported_mixer(c, SOUND_MIXER_PHONEOUT))
|
||||
c->supported_mixers &= ~SOUND_MASK_PHONEOUT;
|
||||
}
|
||||
up(&codec_sem);
|
||||
mutex_unlock(&codec_mutex);
|
||||
} else
|
||||
ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO;
|
||||
|
||||
|
@ -245,9 +245,9 @@ struct cs4281_state {
|
||||
void *tmpbuff; // tmp buffer for sample conversions
|
||||
unsigned ena;
|
||||
spinlock_t lock;
|
||||
struct semaphore open_sem;
|
||||
struct semaphore open_sem_adc;
|
||||
struct semaphore open_sem_dac;
|
||||
struct mutex open_sem;
|
||||
struct mutex open_sem_adc;
|
||||
struct mutex open_sem_dac;
|
||||
mode_t open_mode;
|
||||
wait_queue_head_t open_wait;
|
||||
wait_queue_head_t open_wait_adc;
|
||||
@ -3598,20 +3598,20 @@ static int cs4281_release(struct inode *inode, struct file *file)
|
||||
|
||||
if (file->f_mode & FMODE_WRITE) {
|
||||
drain_dac(s, file->f_flags & O_NONBLOCK);
|
||||
down(&s->open_sem_dac);
|
||||
mutex_lock(&s->open_sem_dac);
|
||||
stop_dac(s);
|
||||
dealloc_dmabuf(s, &s->dma_dac);
|
||||
s->open_mode &= ~FMODE_WRITE;
|
||||
up(&s->open_sem_dac);
|
||||
mutex_unlock(&s->open_sem_dac);
|
||||
wake_up(&s->open_wait_dac);
|
||||
}
|
||||
if (file->f_mode & FMODE_READ) {
|
||||
drain_adc(s, file->f_flags & O_NONBLOCK);
|
||||
down(&s->open_sem_adc);
|
||||
mutex_lock(&s->open_sem_adc);
|
||||
stop_adc(s);
|
||||
dealloc_dmabuf(s, &s->dma_adc);
|
||||
s->open_mode &= ~FMODE_READ;
|
||||
up(&s->open_sem_adc);
|
||||
mutex_unlock(&s->open_sem_adc);
|
||||
wake_up(&s->open_wait_adc);
|
||||
}
|
||||
return 0;
|
||||
@ -3651,33 +3651,33 @@ static int cs4281_open(struct inode *inode, struct file *file)
|
||||
return -ENODEV;
|
||||
}
|
||||
if (file->f_mode & FMODE_WRITE) {
|
||||
down(&s->open_sem_dac);
|
||||
mutex_lock(&s->open_sem_dac);
|
||||
while (s->open_mode & FMODE_WRITE) {
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
up(&s->open_sem_dac);
|
||||
mutex_unlock(&s->open_sem_dac);
|
||||
return -EBUSY;
|
||||
}
|
||||
up(&s->open_sem_dac);
|
||||
mutex_unlock(&s->open_sem_dac);
|
||||
interruptible_sleep_on(&s->open_wait_dac);
|
||||
|
||||
if (signal_pending(current))
|
||||
return -ERESTARTSYS;
|
||||
down(&s->open_sem_dac);
|
||||
mutex_lock(&s->open_sem_dac);
|
||||
}
|
||||
}
|
||||
if (file->f_mode & FMODE_READ) {
|
||||
down(&s->open_sem_adc);
|
||||
mutex_lock(&s->open_sem_adc);
|
||||
while (s->open_mode & FMODE_READ) {
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
up(&s->open_sem_adc);
|
||||
mutex_unlock(&s->open_sem_adc);
|
||||
return -EBUSY;
|
||||
}
|
||||
up(&s->open_sem_adc);
|
||||
mutex_unlock(&s->open_sem_adc);
|
||||
interruptible_sleep_on(&s->open_wait_adc);
|
||||
|
||||
if (signal_pending(current))
|
||||
return -ERESTARTSYS;
|
||||
down(&s->open_sem_adc);
|
||||
mutex_lock(&s->open_sem_adc);
|
||||
}
|
||||
}
|
||||
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
|
||||
@ -3691,7 +3691,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
|
||||
s->ena &= ~FMODE_READ;
|
||||
s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
|
||||
s->dma_adc.subdivision = 0;
|
||||
up(&s->open_sem_adc);
|
||||
mutex_unlock(&s->open_sem_adc);
|
||||
|
||||
if (prog_dmabuf_adc(s)) {
|
||||
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
|
||||
@ -3711,7 +3711,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
|
||||
s->ena &= ~FMODE_WRITE;
|
||||
s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
|
||||
s->dma_dac.subdivision = 0;
|
||||
up(&s->open_sem_dac);
|
||||
mutex_unlock(&s->open_sem_dac);
|
||||
|
||||
if (prog_dmabuf_dac(s)) {
|
||||
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)
|
||||
VALIDATE_STATE(s);
|
||||
file->private_data = s;
|
||||
// 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)) {
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
up(&s->open_sem);
|
||||
mutex_unlock(&s->open_sem);
|
||||
return -EBUSY;
|
||||
}
|
||||
up(&s->open_sem);
|
||||
mutex_unlock(&s->open_sem);
|
||||
interruptible_sleep_on(&s->open_wait);
|
||||
if (signal_pending(current))
|
||||
return -ERESTARTSYS;
|
||||
down(&s->open_sem);
|
||||
mutex_lock(&s->open_sem);
|
||||
}
|
||||
spin_lock_irqsave(&s->lock, flags);
|
||||
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)
|
||||
(file->
|
||||
f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ |
|
||||
FMODE_MIDI_WRITE);
|
||||
up(&s->open_sem);
|
||||
mutex_unlock(&s->open_sem);
|
||||
return nonseekable_open(inode, file);
|
||||
}
|
||||
|
||||
@ -4057,7 +4057,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
|
||||
remove_wait_queue(&s->midi.owait, &wait);
|
||||
current->state = TASK_RUNNING;
|
||||
}
|
||||
down(&s->open_sem);
|
||||
mutex_lock(&s->open_sem);
|
||||
s->open_mode &=
|
||||
(~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ |
|
||||
FMODE_MIDI_WRITE);
|
||||
@ -4067,7 +4067,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
|
||||
del_timer(&s->midi.timer);
|
||||
}
|
||||
spin_unlock_irqrestore(&s->lock, flags);
|
||||
up(&s->open_sem);
|
||||
mutex_unlock(&s->open_sem);
|
||||
wake_up(&s->open_wait);
|
||||
return 0;
|
||||
}
|
||||
@ -4300,9 +4300,9 @@ static int __devinit cs4281_probe(struct pci_dev *pcidev,
|
||||
init_waitqueue_head(&s->open_wait_dac);
|
||||
init_waitqueue_head(&s->midi.iwait);
|
||||
init_waitqueue_head(&s->midi.owait);
|
||||
init_MUTEX(&s->open_sem);
|
||||
init_MUTEX(&s->open_sem_adc);
|
||||
init_MUTEX(&s->open_sem_dac);
|
||||
mutex_init(&s->open_sem);
|
||||
mutex_init(&s->open_sem_adc);
|
||||
mutex_init(&s->open_sem_dac);
|
||||
spin_lock_init(&s->lock);
|
||||
s->pBA0phys = pci_resource_start(pcidev, 0);
|
||||
s->pBA1phys = pci_resource_start(pcidev, 1);
|
||||
|
@ -80,7 +80,7 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/input.h>
|
||||
#include <asm/semaphore.h>
|
||||
#include <linux/mutex.h>
|
||||
#ifdef CONFIG_ADB_CUDA
|
||||
#include <linux/cuda.h>
|
||||
#endif
|
||||
@ -130,7 +130,7 @@ static struct resource awacs_rsrc[3];
|
||||
static char awacs_name[64];
|
||||
static int awacs_revision;
|
||||
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 hw_can_byteswap = 1 ; /* most pmac sound h/w can */
|
||||
@ -312,11 +312,11 @@ extern int daca_enter_sleep(void);
|
||||
extern int daca_leave_sleep(void);
|
||||
|
||||
#define TRY_LOCK() \
|
||||
if ((rc = down_interruptible(&dmasound_sem)) != 0) \
|
||||
if ((rc = mutex_lock_interruptible(&dmasound_mutex)) != 0) \
|
||||
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
|
||||
*
|
||||
|
@ -181,7 +181,7 @@ struct emu10k1_card
|
||||
struct emu10k1_mpuout *mpuout;
|
||||
struct emu10k1_mpuin *mpuin;
|
||||
|
||||
struct semaphore open_sem;
|
||||
struct mutex open_sem;
|
||||
mode_t open_mode;
|
||||
wait_queue_head_t open_wait;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
spin_lock_init(&card->lock);
|
||||
init_MUTEX(&card->open_sem);
|
||||
mutex_init(&card->open_sem);
|
||||
card->open_mode = 0;
|
||||
init_waitqueue_head(&card->open_wait);
|
||||
|
||||
|
@ -110,21 +110,21 @@ match:
|
||||
#endif
|
||||
|
||||
/* 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)) {
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
up(&card->open_sem);
|
||||
mutex_unlock(&card->open_sem);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
up(&card->open_sem);
|
||||
mutex_unlock(&card->open_sem);
|
||||
interruptible_sleep_on(&card->open_wait);
|
||||
|
||||
if (signal_pending(current)) {
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
|
||||
down(&card->open_sem);
|
||||
mutex_lock(&card->open_sem);
|
||||
}
|
||||
|
||||
if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
|
||||
@ -183,7 +183,7 @@ match:
|
||||
|
||||
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);
|
||||
}
|
||||
@ -234,9 +234,9 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file)
|
||||
|
||||
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));
|
||||
up(&card->open_sem);
|
||||
mutex_unlock(&card->open_sem);
|
||||
wake_up_interruptible(&card->open_wait);
|
||||
|
||||
unlock_kernel();
|
||||
|
Loading…
Reference in New Issue
Block a user