From 650224fe8d5f6dbe6cc5875d14bf80da60dd56f8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 27 Feb 2024 09:53:04 +0100 Subject: ALSA: pcm: Use guard() for PCM stream locks Define guard() usage for PCM stream locking and use it in appropriate places. The pair of snd_pcm_stream_lock() and snd_pcm_stream_unlock() can be presented with guard(pcm_stream_lock) now. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20240227085306.9764-23-tiwai@suse.de --- sound/core/pcm_lib.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'sound/core/pcm_lib.c') diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 41103e5c43ce..6f73b3c2c205 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1744,8 +1744,8 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, void *arg) { struct snd_pcm_runtime *runtime = substream->runtime; - unsigned long flags; - snd_pcm_stream_lock_irqsave(substream, flags); + + guard(pcm_stream_lock_irqsave)(substream); if (snd_pcm_running(substream) && snd_pcm_update_hw_ptr(substream) >= 0) runtime->status->hw_ptr %= runtime->buffer_size; @@ -1753,7 +1753,6 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, runtime->status->hw_ptr = 0; runtime->hw_ptr_wrap = 0; } - snd_pcm_stream_unlock_irqrestore(substream, flags); return 0; } @@ -1899,14 +1898,11 @@ EXPORT_SYMBOL(snd_pcm_period_elapsed_under_stream_lock); */ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) { - unsigned long flags; - if (snd_BUG_ON(!substream)) return; - snd_pcm_stream_lock_irqsave(substream, flags); + guard(pcm_stream_lock_irqsave)(substream); snd_pcm_period_elapsed_under_stream_lock(substream); - snd_pcm_stream_unlock_irqrestore(substream, flags); } EXPORT_SYMBOL(snd_pcm_period_elapsed); -- cgit v1.2.3