ALSA: pdaudiocf: 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-11-tiwai@suse.de
This commit is contained in:
parent
7b4d15bcdc
commit
2c24032607
2 changed files with 13 additions and 15 deletions
|
|
@ -161,14 +161,13 @@ static void snd_pdacf_ak4117_change(struct ak4117 *ak4117, unsigned char c0, uns
|
|||
|
||||
if (!(c0 & AK4117_UNLCK))
|
||||
return;
|
||||
mutex_lock(&chip->reg_lock);
|
||||
guard(mutex)(&chip->reg_lock);
|
||||
val = chip->regmap[PDAUDIOCF_REG_SCR>>1];
|
||||
if (ak4117->rcs0 & AK4117_UNLCK)
|
||||
val |= PDAUDIOCF_BLUE_LED_OFF;
|
||||
else
|
||||
val &= ~PDAUDIOCF_BLUE_LED_OFF;
|
||||
pdacf_reg_write(chip, PDAUDIOCF_REG_SCR, val);
|
||||
mutex_unlock(&chip->reg_lock);
|
||||
}
|
||||
|
||||
int snd_pdacf_ak4117_create(struct snd_pdacf *chip)
|
||||
|
|
|
|||
|
|
@ -64,21 +64,20 @@ static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
|
|||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
mutex_lock(&chip->reg_lock);
|
||||
chip->pcm_running += inc;
|
||||
tmp = pdacf_reg_read(chip, PDAUDIOCF_REG_SCR);
|
||||
if (chip->pcm_running) {
|
||||
if ((chip->ak4117->rcs0 & AK4117_UNLCK) || runtime->rate != rate) {
|
||||
chip->pcm_running -= inc;
|
||||
ret = -EIO;
|
||||
goto __end;
|
||||
scoped_guard(mutex, &chip->reg_lock) {
|
||||
chip->pcm_running += inc;
|
||||
tmp = pdacf_reg_read(chip, PDAUDIOCF_REG_SCR);
|
||||
if (chip->pcm_running) {
|
||||
if ((chip->ak4117->rcs0 & AK4117_UNLCK) || runtime->rate != rate) {
|
||||
chip->pcm_running -= inc;
|
||||
ret = -EIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmp &= ~mask;
|
||||
tmp |= val;
|
||||
pdacf_reg_write(chip, PDAUDIOCF_REG_SCR, tmp);
|
||||
}
|
||||
tmp &= ~mask;
|
||||
tmp |= val;
|
||||
pdacf_reg_write(chip, PDAUDIOCF_REG_SCR, tmp);
|
||||
__end:
|
||||
mutex_unlock(&chip->reg_lock);
|
||||
snd_ak4117_check_rate_and_errors(chip->ak4117, AK4117_CHECK_NO_RATE);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue