mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 13:34:30 +00:00
ALSA: seq: virmidi: Use guard() for locking
We can simplify the code gracefully with new guard() macro and co for automatic cleanup of locks. Only the code refactoring, and no functional changes. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20240227085306.9764-20-tiwai@suse.de
This commit is contained in:
parent
6487e36371
commit
a04f2c3960
@ -199,11 +199,10 @@ static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream)
|
||||
vmidi->client = rdev->client;
|
||||
vmidi->port = rdev->port;
|
||||
runtime->private_data = vmidi;
|
||||
down_write(&rdev->filelist_sem);
|
||||
write_lock_irq(&rdev->filelist_lock);
|
||||
list_add_tail(&vmidi->list, &rdev->filelist);
|
||||
write_unlock_irq(&rdev->filelist_lock);
|
||||
up_write(&rdev->filelist_sem);
|
||||
scoped_guard(rwsem_write, &rdev->filelist_sem) {
|
||||
guard(write_lock_irq)(&rdev->filelist_lock);
|
||||
list_add_tail(&vmidi->list, &rdev->filelist);
|
||||
}
|
||||
vmidi->rdev = rdev;
|
||||
return 0;
|
||||
}
|
||||
@ -243,11 +242,10 @@ static int snd_virmidi_input_close(struct snd_rawmidi_substream *substream)
|
||||
struct snd_virmidi_dev *rdev = substream->rmidi->private_data;
|
||||
struct snd_virmidi *vmidi = substream->runtime->private_data;
|
||||
|
||||
down_write(&rdev->filelist_sem);
|
||||
write_lock_irq(&rdev->filelist_lock);
|
||||
list_del(&vmidi->list);
|
||||
write_unlock_irq(&rdev->filelist_lock);
|
||||
up_write(&rdev->filelist_sem);
|
||||
scoped_guard(rwsem_write, &rdev->filelist_sem) {
|
||||
guard(write_lock_irq)(&rdev->filelist_lock);
|
||||
list_del(&vmidi->list);
|
||||
}
|
||||
snd_midi_event_free(vmidi->parser);
|
||||
substream->runtime->private_data = NULL;
|
||||
kfree(vmidi);
|
||||
|
Loading…
x
Reference in New Issue
Block a user