mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 10:01:39 -05:00
ALSA: pcxhr: Use guard() for mutex locks
Replace the manual mutex lock/unlock pairs with guard() for code simplification. Only code refactoring, and no behavior change. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250829144342.4290-49-tiwai@suse.de
This commit is contained in:
@@ -701,7 +701,7 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
|
||||
|
||||
start_time = ktime_get();
|
||||
#endif
|
||||
mutex_lock(&mgr->setup_mutex);
|
||||
guard(mutex)(&mgr->setup_mutex);
|
||||
|
||||
/* check the pipes concerned and build pipe_array */
|
||||
for (i = 0; i < mgr->num_cards; i++) {
|
||||
@@ -720,7 +720,6 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
|
||||
}
|
||||
}
|
||||
if (capture_mask == 0 && playback_mask == 0) {
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
dev_err(&mgr->pci->dev, "%s : no pipes\n", __func__);
|
||||
return;
|
||||
}
|
||||
@@ -731,7 +730,6 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
|
||||
/* synchronous stop of all the pipes concerned */
|
||||
err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
|
||||
if (err) {
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
dev_err(&mgr->pci->dev, "%s : "
|
||||
"error stop pipes (P%x C%x)\n",
|
||||
__func__, playback_mask, capture_mask);
|
||||
@@ -776,7 +774,6 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
|
||||
/* synchronous start of all the pipes concerned */
|
||||
err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
|
||||
if (err) {
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
dev_err(&mgr->pci->dev, "%s : "
|
||||
"error start pipes (P%x C%x)\n",
|
||||
__func__, playback_mask, capture_mask);
|
||||
@@ -786,7 +783,7 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
|
||||
/* put the streams into the running state now
|
||||
* (increment pointer by interrupt)
|
||||
*/
|
||||
mutex_lock(&mgr->lock);
|
||||
guard(mutex)(&mgr->lock);
|
||||
for ( i =0; i < mgr->num_cards; i++) {
|
||||
struct pcxhr_stream *stream;
|
||||
chip = mgr->chip[i];
|
||||
@@ -804,9 +801,6 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex_unlock(&mgr->lock);
|
||||
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
|
||||
#ifdef CONFIG_SND_DEBUG_VERBOSE
|
||||
stop_time = ktime_get();
|
||||
@@ -907,7 +901,7 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
|
||||
subs->runtime->period_size, subs->runtime->periods,
|
||||
subs->runtime->buffer_size);
|
||||
|
||||
mutex_lock(&mgr->setup_mutex);
|
||||
guard(mutex)(&mgr->setup_mutex);
|
||||
|
||||
do {
|
||||
/* only the first stream can choose the sample rate */
|
||||
@@ -923,8 +917,6 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
|
||||
}
|
||||
} while(0); /* do only once (so we can use break instead of goto) */
|
||||
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -939,15 +931,13 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs,
|
||||
struct pcxhr_mgr *mgr = chip->mgr;
|
||||
struct pcxhr_stream *stream = subs->runtime->private_data;
|
||||
|
||||
mutex_lock(&mgr->setup_mutex);
|
||||
guard(mutex)(&mgr->setup_mutex);
|
||||
|
||||
/* set up channels */
|
||||
stream->channels = params_channels(hw);
|
||||
/* set up format for the stream */
|
||||
stream->format = params_format(hw);
|
||||
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -990,7 +980,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
|
||||
struct pcxhr_stream *stream;
|
||||
int err;
|
||||
|
||||
mutex_lock(&mgr->setup_mutex);
|
||||
guard(mutex)(&mgr->setup_mutex);
|
||||
|
||||
/* copy the struct snd_pcm_hardware struct */
|
||||
runtime->hw = pcxhr_caps;
|
||||
@@ -1012,7 +1002,6 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
|
||||
/* streams in use */
|
||||
dev_err(chip->card->dev, "%s chip%d subs%d in use\n",
|
||||
__func__, chip->chip_idx, subs->number);
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
@@ -1023,10 +1012,8 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
|
||||
/* buffer-size should better be multiple of period-size */
|
||||
err = snd_pcm_hw_constraint_integer(runtime,
|
||||
SNDRV_PCM_HW_PARAM_PERIODS);
|
||||
if (err < 0) {
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* if a sample rate is already used or fixed by external clock,
|
||||
* the stream cannot change
|
||||
@@ -1040,7 +1027,6 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
|
||||
&external_rate) ||
|
||||
external_rate == 0) {
|
||||
/* cannot detect the external clock rate */
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
return -EBUSY;
|
||||
}
|
||||
runtime->hw.rate_min = external_rate;
|
||||
@@ -1063,7 +1049,6 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
|
||||
|
||||
mgr->ref_count_rate++;
|
||||
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1074,7 +1059,7 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
|
||||
struct pcxhr_mgr *mgr = chip->mgr;
|
||||
struct pcxhr_stream *stream = subs->runtime->private_data;
|
||||
|
||||
mutex_lock(&mgr->setup_mutex);
|
||||
guard(mutex)(&mgr->setup_mutex);
|
||||
|
||||
dev_dbg(chip->card->dev, "%s chip%d subs%d\n", __func__,
|
||||
chip->chip_idx, subs->number);
|
||||
@@ -1088,8 +1073,6 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
|
||||
stream->status = PCXHR_STREAM_STATUS_FREE;
|
||||
stream->substream = NULL;
|
||||
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1102,14 +1085,12 @@ static snd_pcm_uframes_t pcxhr_stream_pointer(struct snd_pcm_substream *subs)
|
||||
struct snd_pcm_runtime *runtime = subs->runtime;
|
||||
struct pcxhr_stream *stream = runtime->private_data;
|
||||
|
||||
mutex_lock(&chip->mgr->lock);
|
||||
guard(mutex)(&chip->mgr->lock);
|
||||
|
||||
/* get the period fragment and the nb of periods in the buffer */
|
||||
timer_period_frag = stream->timer_period_frag;
|
||||
timer_buf_periods = stream->timer_buf_periods;
|
||||
|
||||
mutex_unlock(&chip->mgr->lock);
|
||||
|
||||
return (snd_pcm_uframes_t)((timer_buf_periods * runtime->period_size) +
|
||||
timer_period_frag);
|
||||
}
|
||||
|
||||
@@ -754,12 +754,8 @@ void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh *rmh, int capture,
|
||||
*/
|
||||
int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
|
||||
{
|
||||
int err;
|
||||
|
||||
mutex_lock(&mgr->msg_lock);
|
||||
err = pcxhr_send_msg_nolock(mgr, rmh);
|
||||
mutex_unlock(&mgr->msg_lock);
|
||||
return err;
|
||||
guard(mutex)(&mgr->msg_lock);
|
||||
return pcxhr_send_msg_nolock(mgr, rmh);
|
||||
}
|
||||
|
||||
static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr)
|
||||
@@ -962,14 +958,13 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
|
||||
struct pcxhr_rmh rmh;
|
||||
int err;
|
||||
|
||||
mutex_lock(&mgr->msg_lock);
|
||||
guard(mutex)(&mgr->msg_lock);
|
||||
if ((mgr->io_num_reg_cont & mask) == value) {
|
||||
dev_dbg(&mgr->pci->dev,
|
||||
"IO_NUM_REG_CONT mask %x already is set to %x\n",
|
||||
mask, value);
|
||||
if (changed)
|
||||
*changed = 0;
|
||||
mutex_unlock(&mgr->msg_lock);
|
||||
return 0; /* already programmed */
|
||||
}
|
||||
pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE);
|
||||
@@ -984,7 +979,6 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
|
||||
if (changed)
|
||||
*changed = 1;
|
||||
}
|
||||
mutex_unlock(&mgr->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1269,7 +1263,7 @@ irqreturn_t pcxhr_threaded_irq(int irq, void *dev_id)
|
||||
int i, j;
|
||||
struct snd_pcxhr *chip;
|
||||
|
||||
mutex_lock(&mgr->lock);
|
||||
guard(mutex)(&mgr->lock);
|
||||
if (mgr->src_it_dsp & PCXHR_IRQ_TIMER) {
|
||||
/* is a 24 bit counter */
|
||||
int dsp_time_new =
|
||||
@@ -1328,6 +1322,5 @@ irqreturn_t pcxhr_threaded_irq(int irq, void *dev_id)
|
||||
}
|
||||
|
||||
pcxhr_msg_thread(mgr);
|
||||
mutex_unlock(&mgr->lock);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -710,9 +710,9 @@ static int hr222_mic_vol_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->mic_volume;
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -721,13 +721,13 @@ static int hr222_mic_vol_put(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
int changed = 0;
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
if (chip->mic_volume != ucontrol->value.integer.value[0]) {
|
||||
changed = 1;
|
||||
chip->mic_volume = ucontrol->value.integer.value[0];
|
||||
hr222_update_analog_audio_level(chip, 1, 0);
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -760,9 +760,9 @@ static int hr222_mic_boost_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->mic_boost;
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -771,13 +771,13 @@ static int hr222_mic_boost_put(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
int changed = 0;
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
if (chip->mic_boost != ucontrol->value.integer.value[0]) {
|
||||
changed = 1;
|
||||
chip->mic_boost = ucontrol->value.integer.value[0];
|
||||
hr222_micro_boost(chip->mgr, chip->mic_boost);
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -800,9 +800,9 @@ static int hr222_phantom_power_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->phantom_power;
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -812,14 +812,13 @@ static int hr222_phantom_power_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
int power, changed = 0;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
power = !!ucontrol->value.integer.value[0];
|
||||
if (chip->phantom_power != power) {
|
||||
hr222_phantom_power(chip->mgr, power);
|
||||
chip->phantom_power = power;
|
||||
changed = 1;
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
if (kcontrol->private_value == 0) { /* playback */
|
||||
ucontrol->value.integer.value[0] = chip->analog_playback_volume[0];
|
||||
ucontrol->value.integer.value[1] = chip->analog_playback_volume[1];
|
||||
@@ -118,7 +119,6 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol,
|
||||
ucontrol->value.integer.value[0] = chip->analog_capture_volume[0];
|
||||
ucontrol->value.integer.value[1] = chip->analog_capture_volume[1];
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
|
||||
int changed = 0;
|
||||
int is_capture, i;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
is_capture = (kcontrol->private_value != 0);
|
||||
for (i = 0; i < 2; i++) {
|
||||
int new_volume = ucontrol->value.integer.value[i];
|
||||
@@ -168,7 +168,6 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol,
|
||||
is_capture, i);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -192,10 +191,9 @@ static int pcxhr_audio_sw_get(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->analog_playback_active[0];
|
||||
ucontrol->value.integer.value[1] = chip->analog_playback_active[1];
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -204,7 +202,8 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
int i, changed = 0;
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
for(i = 0; i < 2; i++) {
|
||||
if (chip->analog_playback_active[i] !=
|
||||
ucontrol->value.integer.value[i]) {
|
||||
@@ -218,7 +217,6 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol,
|
||||
pcxhr_update_analog_audio_level(chip, 0, i);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -352,14 +350,13 @@ static int pcxhr_pcm_vol_get(struct snd_kcontrol *kcontrol,
|
||||
int *stored_volume;
|
||||
int is_capture = kcontrol->private_value;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
if (is_capture) /* digital capture */
|
||||
stored_volume = chip->digital_capture_volume;
|
||||
else /* digital playback */
|
||||
stored_volume = chip->digital_playback_volume[idx];
|
||||
ucontrol->value.integer.value[0] = stored_volume[0];
|
||||
ucontrol->value.integer.value[1] = stored_volume[1];
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -373,7 +370,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
|
||||
int *stored_volume;
|
||||
int i;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
if (is_capture) /* digital capture */
|
||||
stored_volume = chip->digital_capture_volume;
|
||||
else /* digital playback */
|
||||
@@ -392,7 +389,6 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
if (!is_capture && changed) /* update playback volume */
|
||||
pcxhr_update_playback_stream_level(chip, idx);
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -416,10 +412,9 @@ static int pcxhr_pcm_sw_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0];
|
||||
ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1];
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -431,7 +426,7 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol,
|
||||
int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
|
||||
int i, j;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
j = idx;
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (chip->digital_playback_active[j][i] !=
|
||||
@@ -443,7 +438,6 @@ static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
if (changed)
|
||||
pcxhr_update_playback_stream_level(chip, idx);
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -465,10 +459,10 @@ static int pcxhr_monitor_vol_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->monitoring_volume[0];
|
||||
ucontrol->value.integer.value[1] = chip->monitoring_volume[1];
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -479,7 +473,7 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
|
||||
int changed = 0;
|
||||
int i;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (chip->monitoring_volume[i] !=
|
||||
ucontrol->value.integer.value[i]) {
|
||||
@@ -492,7 +486,6 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol,
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -515,10 +508,10 @@ static int pcxhr_monitor_sw_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol);
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
ucontrol->value.integer.value[0] = chip->monitoring_active[0];
|
||||
ucontrol->value.integer.value[1] = chip->monitoring_active[1];
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -529,7 +522,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
|
||||
int changed = 0;
|
||||
int i;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (chip->monitoring_active[i] !=
|
||||
ucontrol->value.integer.value[i]) {
|
||||
@@ -545,7 +538,6 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol,
|
||||
/* update right monitoring volume and mute */
|
||||
pcxhr_update_audio_pipe_level(chip, 0, 1);
|
||||
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return (changed != 0);
|
||||
}
|
||||
|
||||
@@ -671,7 +663,7 @@ static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
if (ucontrol->value.enumerated.item[0] >= i)
|
||||
return -EINVAL;
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) {
|
||||
chip->audio_capture_source = ucontrol->value.enumerated.item[0];
|
||||
if (chip->mgr->is_hr_stereo)
|
||||
@@ -680,7 +672,6 @@ static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol,
|
||||
pcxhr_set_audio_source(chip);
|
||||
ret = 1;
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -760,9 +751,9 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
if (ucontrol->value.enumerated.item[0] >= clock_items)
|
||||
return -EINVAL;
|
||||
mutex_lock(&mgr->mixer_mutex);
|
||||
guard(mutex)(&mgr->mixer_mutex);
|
||||
if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
|
||||
mutex_lock(&mgr->setup_mutex);
|
||||
guard(mutex)(&mgr->setup_mutex);
|
||||
mgr->use_clock_type = ucontrol->value.enumerated.item[0];
|
||||
rate = 0;
|
||||
if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) {
|
||||
@@ -778,10 +769,8 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
|
||||
if (mgr->sample_rate)
|
||||
mgr->sample_rate = rate;
|
||||
}
|
||||
mutex_unlock(&mgr->setup_mutex);
|
||||
ret = 1; /* return 1 even if the set was not done. ok ? */
|
||||
}
|
||||
mutex_unlock(&mgr->mixer_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -814,7 +803,7 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
|
||||
struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
|
||||
int i, err, rate;
|
||||
|
||||
mutex_lock(&mgr->mixer_mutex);
|
||||
guard(mutex)(&mgr->mixer_mutex);
|
||||
for(i = 0; i < 3 + mgr->capture_chips; i++) {
|
||||
if (i == PCXHR_CLOCK_TYPE_INTERNAL)
|
||||
rate = mgr->sample_rate_real;
|
||||
@@ -825,7 +814,6 @@ static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
ucontrol->value.integer.value[i] = rate;
|
||||
}
|
||||
mutex_unlock(&mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -918,7 +906,7 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol,
|
||||
unsigned char aes_bits;
|
||||
int i, err;
|
||||
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
for(i = 0; i < 5; i++) {
|
||||
if (kcontrol->private_value == 0) /* playback */
|
||||
aes_bits = chip->aes_bits[i];
|
||||
@@ -934,7 +922,6 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol,
|
||||
}
|
||||
ucontrol->value.iec958.status[i] = aes_bits;
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -988,7 +975,7 @@ static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol,
|
||||
int i, changed = 0;
|
||||
|
||||
/* playback */
|
||||
mutex_lock(&chip->mgr->mixer_mutex);
|
||||
guard(mutex)(&chip->mgr->mixer_mutex);
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) {
|
||||
if (chip->mgr->is_hr_stereo)
|
||||
@@ -1000,7 +987,6 @@ static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol,
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&chip->mgr->mixer_mutex);
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user