Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+5 -10
+3 -6
sound/pcmcia/vx/vxp_mixer.c
··· 43 43 44 44 if (val > MIC_LEVEL_MAX) 45 45 return -EINVAL; 46 - mutex_lock(&_chip->mixer_mutex); 46 + guard(mutex)(&_chip->mixer_mutex); 47 47 if (chip->mic_level != ucontrol->value.integer.value[0]) { 48 48 vx_set_mic_level(_chip, ucontrol->value.integer.value[0]); 49 49 chip->mic_level = ucontrol->value.integer.value[0]; 50 - mutex_unlock(&_chip->mixer_mutex); 51 50 return 1; 52 51 } 53 - mutex_unlock(&_chip->mixer_mutex); 54 52 return 0; 55 53 } 56 54 ··· 83 85 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 84 86 struct snd_vxpocket *chip = to_vxpocket(_chip); 85 87 int val = !!ucontrol->value.integer.value[0]; 86 - mutex_lock(&_chip->mixer_mutex); 88 + 89 + guard(mutex)(&_chip->mixer_mutex); 87 90 if (chip->mic_level != val) { 88 91 vx_set_mic_boost(_chip, val); 89 92 chip->mic_level = val; 90 - mutex_unlock(&_chip->mixer_mutex); 91 93 return 1; 92 94 } 93 - mutex_unlock(&_chip->mixer_mutex); 94 95 return 0; 95 96 } 96 97
+2 -4
sound/pcmcia/vx/vxp_ops.c
··· 463 463 if (chip->chip_status & VX_STAT_IS_STALE) 464 464 return; 465 465 466 - mutex_lock(&chip->lock); 466 + guard(mutex)(&chip->lock); 467 467 if (pchip->regCDSP & P24_CDSP_MICS_SEL_MASK) { 468 468 if (boost) { 469 469 /* boost: 38 dB */ ··· 476 476 } 477 477 vx_outb(chip, CDSP, pchip->regCDSP); 478 478 } 479 - mutex_unlock(&chip->lock); 480 479 } 481 480 482 481 /* ··· 504 505 if (chip->chip_status & VX_STAT_IS_STALE) 505 506 return; 506 507 507 - mutex_lock(&chip->lock); 508 + guard(mutex)(&chip->lock); 508 509 if (pchip->regCDSP & VXP_CDSP_MIC_SEL_MASK) { 509 510 level = vx_compute_mic_level(level); 510 511 vx_outb(chip, MICRO, level); 511 512 } 512 - mutex_unlock(&chip->lock); 513 513 } 514 514 515 515