Skip to content

Commit fe33755

Browse files
tiwaigregkh
authored andcommitted
ALSA: misc: Use guard() for spin locks
[ Upstream commit b8e1684 ] 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 Stable-dep-of: 5337213 ("ALSA: core: Serialize deferred fasync state checks") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 409fb34 commit fe33755

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

sound/core/misc.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,35 +202,30 @@ int snd_fasync_helper(int fd, struct file *file, int on,
202202
INIT_LIST_HEAD(&fasync->list);
203203
}
204204

205-
spin_lock_irq(&snd_fasync_lock);
206-
if (*fasyncp) {
207-
kfree(fasync);
208-
fasync = *fasyncp;
209-
} else {
210-
if (!fasync) {
211-
spin_unlock_irq(&snd_fasync_lock);
212-
return 0;
205+
scoped_guard(spinlock_irq, &snd_fasync_lock) {
206+
if (*fasyncp) {
207+
kfree(fasync);
208+
fasync = *fasyncp;
209+
} else {
210+
if (!fasync)
211+
return 0;
212+
*fasyncp = fasync;
213213
}
214-
*fasyncp = fasync;
214+
fasync->on = on;
215215
}
216-
fasync->on = on;
217-
spin_unlock_irq(&snd_fasync_lock);
218216
return fasync_helper(fd, file, on, &fasync->fasync);
219217
}
220218
EXPORT_SYMBOL_GPL(snd_fasync_helper);
221219

222220
void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll)
223221
{
224-
unsigned long flags;
225-
226222
if (!fasync || !fasync->on)
227223
return;
228-
spin_lock_irqsave(&snd_fasync_lock, flags);
224+
guard(spinlock_irqsave)(&snd_fasync_lock);
229225
fasync->signal = signal;
230226
fasync->poll = poll;
231227
list_move(&fasync->list, &snd_fasync_list);
232228
schedule_work(&snd_fasync_work);
233-
spin_unlock_irqrestore(&snd_fasync_lock, flags);
234229
}
235230
EXPORT_SYMBOL_GPL(snd_kill_fasync);
236231

0 commit comments

Comments
 (0)