diff options
author | Takashi Iwai <tiwai@suse.de> | 2024-02-27 11:53:01 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2024-02-28 17:01:22 +0300 |
commit | a04f2c396031a33a1df51c9c6012650a40ba9d7e (patch) | |
tree | da36b0c6e9158ed562ace2f73d35941db929f3f6 /sound/core | |
parent | 6487e363714c28c4b62ac149e7d907cfeeedb3ad (diff) | |
download | linux-a04f2c396031a33a1df51c9c6012650a40ba9d7e.tar.xz |
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
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/seq/seq_virmidi.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 35f93b43dd2a..b4672613c261 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -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); |