ALSA: sb: 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/20250829145300.5460-13-tiwai@suse.de
This commit is contained in:
Takashi Iwai
2025-08-29 16:52:52 +02:00
parent 949ffce4af
commit d994b2ba8f

View File

@@ -265,14 +265,10 @@ static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file)
*/
static int snd_sb_csp_use(struct snd_sb_csp * p)
{
mutex_lock(&p->access_mutex);
if (p->used) {
mutex_unlock(&p->access_mutex);
guard(mutex)(&p->access_mutex);
if (p->used)
return -EAGAIN;
}
p->used++;
mutex_unlock(&p->access_mutex);
return 0;
}
@@ -282,10 +278,8 @@ static int snd_sb_csp_use(struct snd_sb_csp * p)
*/
static int snd_sb_csp_unuse(struct snd_sb_csp * p)
{
mutex_lock(&p->access_mutex);
guard(mutex)(&p->access_mutex);
p->used--;
mutex_unlock(&p->access_mutex);
return 0;
}