]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: misc: Use guard() for spin locks
authorTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 15:13:33 +0000 (17:13 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Sep 2025 11:54:28 +0000 (13:54 +0200)
Clean up the code using guard() for spin locks.

Merely code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250829151335.7342-20-tiwai@suse.de
sound/core/misc.c

index c2fda3bd90a0d4c8ed6bf23e4e1206ef6c1712e3..88d9e1f9a6e9ff4a53039596368b599378b05f11 100644 (file)
@@ -127,35 +127,30 @@ int snd_fasync_helper(int fd, struct file *file, int on,
                INIT_LIST_HEAD(&fasync->list);
        }
 
-       spin_lock_irq(&snd_fasync_lock);
-       if (*fasyncp) {
-               kfree(fasync);
-               fasync = *fasyncp;
-       } else {
-               if (!fasync) {
-                       spin_unlock_irq(&snd_fasync_lock);
-                       return 0;
+       scoped_guard(spinlock_irq, &snd_fasync_lock) {
+               if (*fasyncp) {
+                       kfree(fasync);
+                       fasync = *fasyncp;
+               } else {
+                       if (!fasync)
+                               return 0;
+                       *fasyncp = fasync;
                }
-               *fasyncp = fasync;
+               fasync->on = on;
        }
-       fasync->on = on;
-       spin_unlock_irq(&snd_fasync_lock);
        return fasync_helper(fd, file, on, &fasync->fasync);
 }
 EXPORT_SYMBOL_GPL(snd_fasync_helper);
 
 void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll)
 {
-       unsigned long flags;
-
        if (!fasync || !fasync->on)
                return;
-       spin_lock_irqsave(&snd_fasync_lock, flags);
+       guard(spinlock_irqsave)(&snd_fasync_lock);
        fasync->signal = signal;
        fasync->poll = poll;
        list_move(&fasync->list, &snd_fasync_list);
        schedule_work(&snd_fasync_work);
-       spin_unlock_irqrestore(&snd_fasync_lock, flags);
 }
 EXPORT_SYMBOL_GPL(snd_kill_fasync);