mirror of
https://github.com/torvalds/linux.git
synced 2025-11-30 23:16:01 +07:00
ALSA: vxpocket: 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/20250829151335.7342-12-tiwai@suse.de
This commit is contained in:
@@ -43,14 +43,12 @@ static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
|
||||
|
||||
if (val > MIC_LEVEL_MAX)
|
||||
return -EINVAL;
|
||||
mutex_lock(&_chip->mixer_mutex);
|
||||
guard(mutex)(&_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];
|
||||
mutex_unlock(&_chip->mixer_mutex);
|
||||
return 1;
|
||||
}
|
||||
mutex_unlock(&_chip->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -85,14 +83,13 @@ 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 = to_vxpocket(_chip);
|
||||
int val = !!ucontrol->value.integer.value[0];
|
||||
mutex_lock(&_chip->mixer_mutex);
|
||||
|
||||
guard(mutex)(&_chip->mixer_mutex);
|
||||
if (chip->mic_level != val) {
|
||||
vx_set_mic_boost(_chip, val);
|
||||
chip->mic_level = val;
|
||||
mutex_unlock(&_chip->mixer_mutex);
|
||||
return 1;
|
||||
}
|
||||
mutex_unlock(&_chip->mixer_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ void vx_set_mic_boost(struct vx_core *chip, int boost)
|
||||
if (chip->chip_status & VX_STAT_IS_STALE)
|
||||
return;
|
||||
|
||||
mutex_lock(&chip->lock);
|
||||
guard(mutex)(&chip->lock);
|
||||
if (pchip->regCDSP & P24_CDSP_MICS_SEL_MASK) {
|
||||
if (boost) {
|
||||
/* boost: 38 dB */
|
||||
@@ -476,7 +476,6 @@ void vx_set_mic_boost(struct vx_core *chip, int boost)
|
||||
}
|
||||
vx_outb(chip, CDSP, pchip->regCDSP);
|
||||
}
|
||||
mutex_unlock(&chip->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -505,12 +504,11 @@ void vx_set_mic_level(struct vx_core *chip, int level)
|
||||
if (chip->chip_status & VX_STAT_IS_STALE)
|
||||
return;
|
||||
|
||||
mutex_lock(&chip->lock);
|
||||
guard(mutex)(&chip->lock);
|
||||
if (pchip->regCDSP & VXP_CDSP_MIC_SEL_MASK) {
|
||||
level = vx_compute_mic_level(level);
|
||||
vx_outb(chip, MICRO, level);
|
||||
}
|
||||
mutex_unlock(&chip->lock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user