diff options
| author | Takashi Iwai <tiwai@suse.de> | 2025-08-29 17:13:33 +0200 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2025-09-01 13:54:28 +0200 |
| commit | b8e1684163ae52db90f428965bd9aaff7205c02e (patch) | |
| tree | 9051687fb8ef0816d5e504af4e30bf606bf6ef1f /sound/core | |
| parent | 69f374931fa4714891cad0a0558b415f80aa7225 (diff) | |
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
Diffstat (limited to 'sound/core')
| -rw-r--r-- | sound/core/misc.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/sound/core/misc.c b/sound/core/misc.c index c2fda3bd90a0..88d9e1f9a6e9 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -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); |
