Commit befceea9 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] echoaudio - convert from semaphore to mutex

Converted from semaphore to mutex.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent e3cde64a
...@@ -378,7 +378,7 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream) ...@@ -378,7 +378,7 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream)
DE_ACT(("pcm_digital_in_open\n")); DE_ACT(("pcm_digital_in_open\n"));
max_channels = num_digital_busses_in(chip) - substream->number; max_channels = num_digital_busses_in(chip) - substream->number;
down(&chip->mode_mutex); mutex_lock(&chip->mode_mutex);
if (chip->digital_mode == DIGITAL_MODE_ADAT) if (chip->digital_mode == DIGITAL_MODE_ADAT)
err = pcm_open(substream, max_channels); err = pcm_open(substream, max_channels);
else /* If the card has ADAT, subtract the 6 channels else /* If the card has ADAT, subtract the 6 channels
...@@ -405,7 +405,7 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream) ...@@ -405,7 +405,7 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream)
chip->can_set_rate=0; chip->can_set_rate=0;
din_exit: din_exit:
up(&chip->mode_mutex); mutex_unlock(&chip->mode_mutex);
return err; return err;
} }
...@@ -420,7 +420,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream) ...@@ -420,7 +420,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream)
DE_ACT(("pcm_digital_out_open\n")); DE_ACT(("pcm_digital_out_open\n"));
max_channels = num_digital_busses_out(chip) - substream->number; max_channels = num_digital_busses_out(chip) - substream->number;
down(&chip->mode_mutex); mutex_lock(&chip->mode_mutex);
if (chip->digital_mode == DIGITAL_MODE_ADAT) if (chip->digital_mode == DIGITAL_MODE_ADAT)
err = pcm_open(substream, max_channels); err = pcm_open(substream, max_channels);
else /* If the card has ADAT, subtract the 6 channels else /* If the card has ADAT, subtract the 6 channels
...@@ -447,7 +447,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream) ...@@ -447,7 +447,7 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream)
if (atomic_read(&chip->opencount) > 1 && chip->rate_set) if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
chip->can_set_rate=0; chip->can_set_rate=0;
dout_exit: dout_exit:
up(&chip->mode_mutex); mutex_unlock(&chip->mode_mutex);
return err; return err;
} }
...@@ -1420,7 +1420,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol, ...@@ -1420,7 +1420,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol,
if (dmode != chip->digital_mode) { if (dmode != chip->digital_mode) {
/* mode_mutex is required to make this operation atomic wrt /* mode_mutex is required to make this operation atomic wrt
pcm_digital_*_open() and set_input_clock() functions. */ pcm_digital_*_open() and set_input_clock() functions. */
down(&chip->mode_mutex); mutex_lock(&chip->mode_mutex);
/* Do not allow the user to change the digital mode when a pcm /* Do not allow the user to change the digital mode when a pcm
device is open because it also changes the number of channels device is open because it also changes the number of channels
...@@ -1439,7 +1439,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol, ...@@ -1439,7 +1439,7 @@ static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol,
if (changed >= 0) if (changed >= 0)
changed = 1; /* No errors */ changed = 1; /* No errors */
} }
up(&chip->mode_mutex); mutex_unlock(&chip->mode_mutex);
} }
return changed; return changed;
} }
...@@ -1566,12 +1566,12 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol, ...@@ -1566,12 +1566,12 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol,
return -EINVAL; return -EINVAL;
dclock = chip->clock_source_list[eclock]; dclock = chip->clock_source_list[eclock];
if (chip->input_clock != dclock) { if (chip->input_clock != dclock) {
down(&chip->mode_mutex); mutex_lock(&chip->mode_mutex);
spin_lock_irq(&chip->lock); spin_lock_irq(&chip->lock);
if ((changed = set_input_clock(chip, dclock)) == 0) if ((changed = set_input_clock(chip, dclock)) == 0)
changed = 1; /* no errors */ changed = 1; /* no errors */
spin_unlock_irq(&chip->lock); spin_unlock_irq(&chip->lock);
up(&chip->mode_mutex); mutex_unlock(&chip->mode_mutex);
} }
if (changed < 0) if (changed < 0)
...@@ -1972,7 +1972,7 @@ static __devinit int snd_echo_create(struct snd_card *card, ...@@ -1972,7 +1972,7 @@ static __devinit int snd_echo_create(struct snd_card *card,
return err; return err;
} }
atomic_set(&chip->opencount, 0); atomic_set(&chip->opencount, 0);
init_MUTEX(&chip->mode_mutex); mutex_init(&chip->mode_mutex);
chip->can_set_rate = 1; chip->can_set_rate = 1;
*rchip = chip; *rchip = chip;
/* Init done ! */ /* Init done ! */
......
...@@ -361,7 +361,7 @@ struct echoaudio { ...@@ -361,7 +361,7 @@ struct echoaudio {
spinlock_t lock; spinlock_t lock;
struct snd_pcm_substream *substream[DSP_MAXPIPES]; struct snd_pcm_substream *substream[DSP_MAXPIPES];
int last_period[DSP_MAXPIPES]; int last_period[DSP_MAXPIPES];
struct semaphore mode_mutex; struct mutex mode_mutex;
u16 num_digital_modes, digital_mode_list[6]; u16 num_digital_modes, digital_mode_list[6];
u16 num_clock_sources, clock_source_list[10]; u16 num_clock_sources, clock_source_list[10];
atomic_t opencount; atomic_t opencount;
......
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