summaryrefslogtreecommitdiff
path: root/sound/core/pcm_native.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2021-02-06 23:36:56 +0300
committerTakashi Iwai <tiwai@suse.de>2021-02-08 18:01:01 +0300
commit8d19b4e0b377e226b98f26ded5f0c6463976e4fb (patch)
tree2018d108a523f8c192748d4181a0aea31192010d /sound/core/pcm_native.c
parent700cb70730777c159a988e01daa93f20a1ae9b58 (diff)
downloadlinux-8d19b4e0b377e226b98f26ded5f0c6463976e4fb.tar.xz
ALSA: pcm: Use for_each_pcm_substream() macro
There are a few places doing the same loop iterating all PCM substreams belonging to the PCM object. Introduce a local helper macro, for_each_pcm_substream(), to simplify the code. Link: https://lore.kernel.org/r/20210206203656.15959-5-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm_native.c')
-rw-r--r--sound/core/pcm_native.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 0ae2475465ab..17a85f4815d5 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1674,30 +1674,25 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm)
if (! pcm)
return 0;
- for (stream = 0; stream < 2; stream++) {
- for (substream = pcm->streams[stream].substream;
- substream; substream = substream->next) {
- /* FIXME: the open/close code should lock this as well */
- if (substream->runtime == NULL)
- continue;
+ for_each_pcm_substream(pcm, stream, substream) {
+ /* FIXME: the open/close code should lock this as well */
+ if (!substream->runtime)
+ continue;
- /*
- * Skip BE dai link PCM's that are internal and may
- * not have their substream ops set.
- */
- if (!substream->ops)
- continue;
+ /*
+ * Skip BE dai link PCM's that are internal and may
+ * not have their substream ops set.
+ */
+ if (!substream->ops)
+ continue;
- err = snd_pcm_suspend(substream);
- if (err < 0 && err != -EBUSY)
- return err;
- }
+ err = snd_pcm_suspend(substream);
+ if (err < 0 && err != -EBUSY)
+ return err;
}
- for (stream = 0; stream < 2; stream++)
- for (substream = pcm->streams[stream].substream;
- substream; substream = substream->next)
- snd_pcm_sync_stop(substream, false);
+ for_each_pcm_substream(pcm, stream, substream)
+ snd_pcm_sync_stop(substream, false);
return 0;
}