]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: sb: Use guard() for mutex locks
authorTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 14:52:52 +0000 (16:52 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Sep 2025 11:53:02 +0000 (13:53 +0200)
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
sound/isa/sb/sb16_csp.c

index 7034072c80d415071f5e46272ddfaa635225eaa4..7c5072e4a96f7930348e8df70478c8362779def2 100644 (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;
 }