Skip to content

Commit

Permalink
[ALSA] semaphore -> mutex (Archs, misc buses)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Ingo Molnar authored and Jaroslav Kysela committed Mar 22, 2006
1 parent 62932df commit 12aa757
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 54 deletions.
10 changes: 5 additions & 5 deletions sound/arm/aaci.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned
if (ac97->num >= 4)
return;

down(&aaci->ac97_sem);
mutex_lock(&aaci->ac97_sem);

aaci_ac97_select_codec(aaci, ac97);

Expand All @@ -91,7 +91,7 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned
v = readl(aaci->base + AACI_SLFR);
} while (v & (SLFR_1TXB|SLFR_2TXB));

up(&aaci->ac97_sem);
mutex_unlock(&aaci->ac97_sem);
}

/*
Expand All @@ -105,7 +105,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
if (ac97->num >= 4)
return ~0;

down(&aaci->ac97_sem);
mutex_lock(&aaci->ac97_sem);

aaci_ac97_select_codec(aaci, ac97);

Expand Down Expand Up @@ -145,7 +145,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
v = ~0;
}

up(&aaci->ac97_sem);
mutex_unlock(&aaci->ac97_sem);
return v;
}

Expand Down Expand Up @@ -783,7 +783,7 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
card->shortname, dev->res.start, dev->irq[0]);

aaci = card->private_data;
init_MUTEX(&aaci->ac97_sem);
mutex_init(&aaci->ac97_sem);
spin_lock_init(&aaci->lock);
aaci->card = card;
aaci->dev = dev;
Expand Down
2 changes: 1 addition & 1 deletion sound/arm/aaci.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct aaci {
unsigned int fifosize;

/* AC'97 */
struct semaphore ac97_sem;
struct mutex ac97_sem;
ac97_bus_t *ac97_bus;

u32 maincr;
Expand Down
12 changes: 6 additions & 6 deletions sound/arm/pxa2xx-ac97.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
#include <sound/initval.h>

#include <asm/irq.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <asm/hardware.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/audio.h>

#include "pxa2xx-pcm.h"


static DECLARE_MUTEX(car_mutex);
static DEFINE_MUTEX(car_mutex);
static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
static volatile long gsr_bits;

Expand All @@ -52,7 +52,7 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg
unsigned short val = -1;
volatile u32 *reg_addr;

down(&car_mutex);
mutex_lock(&car_mutex);

/* set up primary or secondary codec space */
reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;
Expand All @@ -79,15 +79,15 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg
/* but we've just started another cycle... */
wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);

out: up(&car_mutex);
out: mutex_unlock(&car_mutex);
return val;
}

static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
{
volatile u32 *reg_addr;

down(&car_mutex);
mutex_lock(&car_mutex);

/* set up primary or secondary codec space */
reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE;
Expand All @@ -101,7 +101,7 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigne
printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
__FUNCTION__, reg, GSR | gsr_bits);

up(&car_mutex);
mutex_unlock(&car_mutex);
}

static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
Expand Down
12 changes: 6 additions & 6 deletions sound/pcmcia/vx/vxp_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
{
struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
down(&_chip->mixer_mutex);
mutex_lock(&_chip->mixer_mutex);
if (chip->mic_level != ucontrol->value.integer.value[0]) {
vx_set_mic_level(_chip, ucontrol->value.integer.value[0]);
chip->mic_level = ucontrol->value.integer.value[0];
up(&_chip->mixer_mutex);
mutex_unlock(&_chip->mixer_mutex);
return 1;
}
up(&_chip->mixer_mutex);
mutex_unlock(&_chip->mixer_mutex);
return 0;
}

Expand Down Expand Up @@ -95,14 +95,14 @@ static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
{
struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
down(&_chip->mixer_mutex);
mutex_lock(&_chip->mixer_mutex);
if (chip->mic_level != ucontrol->value.integer.value[0]) {
vx_set_mic_boost(_chip, ucontrol->value.integer.value[0]);
chip->mic_level = ucontrol->value.integer.value[0];
up(&_chip->mixer_mutex);
mutex_unlock(&_chip->mixer_mutex);
return 1;
}
up(&_chip->mixer_mutex);
mutex_unlock(&_chip->mixer_mutex);
return 0;
}

Expand Down
34 changes: 17 additions & 17 deletions sound/sparc/cs4231.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ struct snd_cs4231 {
unsigned char image[32]; /* registers image */
int mce_bit;
int calibrate_mute;
struct semaphore mce_mutex;
struct semaphore open_mutex;
struct mutex mce_mutex;
struct mutex open_mutex;

union {
#ifdef SBUS_SUPPORT
Expand Down Expand Up @@ -775,7 +775,7 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_h
{
unsigned long flags;

down(&chip->mce_mutex);
mutex_lock(&chip->mce_mutex);
snd_cs4231_calibrate_mute(chip, 1);

snd_cs4231_mce_up(chip);
Expand All @@ -790,15 +790,15 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_h
snd_cs4231_mce_down(chip);

snd_cs4231_calibrate_mute(chip, 0);
up(&chip->mce_mutex);
mutex_unlock(&chip->mce_mutex);
}

static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params,
unsigned char cdfr)
{
unsigned long flags;

down(&chip->mce_mutex);
mutex_lock(&chip->mce_mutex);
snd_cs4231_calibrate_mute(chip, 1);

snd_cs4231_mce_up(chip);
Expand All @@ -819,7 +819,7 @@ static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw
snd_cs4231_mce_down(chip);

snd_cs4231_calibrate_mute(chip, 0);
up(&chip->mce_mutex);
mutex_unlock(&chip->mce_mutex);
}

/*
Expand Down Expand Up @@ -933,14 +933,14 @@ static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
{
unsigned long flags;

down(&chip->open_mutex);
mutex_lock(&chip->open_mutex);
if ((chip->mode & mode)) {
up(&chip->open_mutex);
mutex_unlock(&chip->open_mutex);
return -EAGAIN;
}
if (chip->mode & CS4231_MODE_OPEN) {
chip->mode |= mode;
up(&chip->open_mutex);
mutex_unlock(&chip->open_mutex);
return 0;
}
/* ok. now enable and ack CODEC IRQ */
Expand All @@ -960,18 +960,18 @@ static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
spin_unlock_irqrestore(&chip->lock, flags);

chip->mode = mode;
up(&chip->open_mutex);
mutex_unlock(&chip->open_mutex);
return 0;
}

static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
{
unsigned long flags;

down(&chip->open_mutex);
mutex_lock(&chip->open_mutex);
chip->mode &= ~mode;
if (chip->mode & CS4231_MODE_OPEN) {
up(&chip->open_mutex);
mutex_unlock(&chip->open_mutex);
return;
}
snd_cs4231_calibrate_mute(chip, 1);
Expand Down Expand Up @@ -1008,7 +1008,7 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
snd_cs4231_calibrate_mute(chip, 0);

chip->mode = 0;
up(&chip->open_mutex);
mutex_unlock(&chip->open_mutex);
}

/*
Expand Down Expand Up @@ -1969,8 +1969,8 @@ static int __init snd_cs4231_sbus_create(struct snd_card *card,
spin_lock_init(&chip->lock);
spin_lock_init(&chip->c_dma.sbus_info.lock);
spin_lock_init(&chip->p_dma.sbus_info.lock);
init_MUTEX(&chip->mce_mutex);
init_MUTEX(&chip->open_mutex);
mutex_init(&chip->mce_mutex);
mutex_init(&chip->open_mutex);
chip->card = card;
chip->dev_u.sdev = sdev;
chip->regs_size = sdev->reg_addrs[0].reg_size;
Expand Down Expand Up @@ -2157,8 +2157,8 @@ static int __init snd_cs4231_ebus_create(struct snd_card *card,
spin_lock_init(&chip->lock);
spin_lock_init(&chip->c_dma.ebus_info.lock);
spin_lock_init(&chip->p_dma.ebus_info.lock);
init_MUTEX(&chip->mce_mutex);
init_MUTEX(&chip->open_mutex);
mutex_init(&chip->mce_mutex);
mutex_init(&chip->open_mutex);
chip->flags |= CS4231_FLAG_EBUS;
chip->card = card;
chip->dev_u.pdev = edev->bus->self;
Expand Down
15 changes: 8 additions & 7 deletions sound/usb/usbaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <linux/usb.h>
#include <linux/vmalloc.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/pcm.h>
Expand Down Expand Up @@ -202,7 +203,7 @@ struct snd_usb_stream {
* the all interfaces on the same card as one sound device.
*/

static DECLARE_MUTEX(register_mutex);
static DEFINE_MUTEX(register_mutex);
static struct snd_usb_audio *usb_chip[SNDRV_CARDS];


Expand Down Expand Up @@ -3285,7 +3286,7 @@ static void *snd_usb_audio_probe(struct usb_device *dev,

/* check whether it's already registered */
chip = NULL;
down(&register_mutex);
mutex_lock(&register_mutex);
for (i = 0; i < SNDRV_CARDS; i++) {
if (usb_chip[i] && usb_chip[i]->dev == dev) {
if (usb_chip[i]->shutdown) {
Expand Down Expand Up @@ -3338,13 +3339,13 @@ static void *snd_usb_audio_probe(struct usb_device *dev,

usb_chip[chip->index] = chip;
chip->num_interfaces++;
up(&register_mutex);
mutex_unlock(&register_mutex);
return chip;

__error:
if (chip && !chip->num_interfaces)
snd_card_free(chip->card);
up(&register_mutex);
mutex_unlock(&register_mutex);
__err_val:
return NULL;
}
Expand All @@ -3364,7 +3365,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)

chip = ptr;
card = chip->card;
down(&register_mutex);
mutex_lock(&register_mutex);
chip->shutdown = 1;
chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
Expand All @@ -3382,10 +3383,10 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)
snd_usb_mixer_disconnect(p);
}
usb_chip[chip->index] = NULL;
up(&register_mutex);
mutex_unlock(&register_mutex);
snd_card_free(card);
} else {
up(&register_mutex);
mutex_unlock(&register_mutex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sound/usb/usx2y/usbusx2y.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device)
usX2Y(card)->chip.dev = device;
usX2Y(card)->chip.card = card;
init_waitqueue_head(&usX2Y(card)->prepare_wait_queue);
init_MUTEX (&usX2Y(card)->prepare_mutex);
mutex_init(&usX2Y(card)->prepare_mutex);
INIT_LIST_HEAD(&usX2Y(card)->chip.midi_list);
strcpy(card->driver, "USB "NAME_ALLCAPS"");
sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
Expand Down
2 changes: 1 addition & 1 deletion sound/usb/usx2y/usbusx2y.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct usX2Ydev {
unsigned int rate,
format;
int chip_status;
struct semaphore prepare_mutex;
struct mutex prepare_mutex;
struct us428ctls_sharedmem *us428ctls_sharedmem;
int wait_iso_frame;
wait_queue_head_t us428ctls_wait_queue_head;
Expand Down
8 changes: 4 additions & 4 deletions sound/usb/usx2y/usbusx2yaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_usX2Y_substream *subs = runtime->private_data;
down(&subs->usX2Y->prepare_mutex);
mutex_lock(&subs->usX2Y->prepare_mutex);
snd_printdd("snd_usX2Y_hw_free(%p)\n", substream);

if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
Expand All @@ -832,7 +832,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
usX2Y_urbs_release(subs);
}
}
up(&subs->usX2Y->prepare_mutex);
mutex_unlock(&subs->usX2Y->prepare_mutex);
return snd_pcm_lib_free_pages(substream);
}
/*
Expand All @@ -849,7 +849,7 @@ static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream)
int err = 0;
snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream);

down(&usX2Y->prepare_mutex);
mutex_lock(&usX2Y->prepare_mutex);
usX2Y_subs_prepare(subs);
// Start hardware streams
// SyncStream first....
Expand All @@ -869,7 +869,7 @@ static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream)
err = usX2Y_urbs_start(subs);

up_prepare_mutex:
up(&usX2Y->prepare_mutex);
mutex_unlock(&usX2Y->prepare_mutex);
return err;
}

Expand Down
Loading

0 comments on commit 12aa757

Please sign in to comment.