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: misc: Use guard() for spin locks

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

+10 -15
+10 -15
sound/core/misc.c
··· 127 127 INIT_LIST_HEAD(&fasync->list); 128 128 } 129 129 130 - spin_lock_irq(&snd_fasync_lock); 131 - if (*fasyncp) { 132 - kfree(fasync); 133 - fasync = *fasyncp; 134 - } else { 135 - if (!fasync) { 136 - spin_unlock_irq(&snd_fasync_lock); 137 - return 0; 130 + scoped_guard(spinlock_irq, &snd_fasync_lock) { 131 + if (*fasyncp) { 132 + kfree(fasync); 133 + fasync = *fasyncp; 134 + } else { 135 + if (!fasync) 136 + return 0; 137 + *fasyncp = fasync; 138 138 } 139 - *fasyncp = fasync; 139 + fasync->on = on; 140 140 } 141 - fasync->on = on; 142 - spin_unlock_irq(&snd_fasync_lock); 143 141 return fasync_helper(fd, file, on, &fasync->fasync); 144 142 } 145 143 EXPORT_SYMBOL_GPL(snd_fasync_helper); 146 144 147 145 void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll) 148 146 { 149 - unsigned long flags; 150 - 151 147 if (!fasync || !fasync->on) 152 148 return; 153 - spin_lock_irqsave(&snd_fasync_lock, flags); 149 + guard(spinlock_irqsave)(&snd_fasync_lock); 154 150 fasync->signal = signal; 155 151 fasync->poll = poll; 156 152 list_move(&fasync->list, &snd_fasync_list); 157 153 schedule_work(&snd_fasync_work); 158 - spin_unlock_irqrestore(&snd_fasync_lock, flags); 159 154 } 160 155 EXPORT_SYMBOL_GPL(snd_kill_fasync); 161 156