From: "Alvin Šipraga" <alvin.sipraga@analog.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Mark Brown <broonie@kernel.org>, linux-sound@vger.kernel.org
Subject: Re: [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list()
Date: Tue, 15 Sep 2026 17:03:45 +0200 [thread overview]
Message-ID: <aqlUINu_YUeN9O47@analog.com> (raw)
In-Reply-To: <87ld94li94.wl-kuninori.morimoto.gx@renesas.com>
On Mon, Sep 14, 2026 at 01:43:51AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. add snd_soc_dai_{to/from}_list() to use for_each macro.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> include/sound/soc-component.h | 14 ++++++++++----
> include/sound/soc-dai.h | 2 ++
> sound/soc/soc-dai.c | 12 ++++++++++++
> 3 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
> index c49b59630101f..6c1acc984ecb0 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -258,10 +258,16 @@ struct snd_soc_component {
> void *priv;
> };
>
> -#define for_each_component_dais(component, dai)\
> - list_for_each_entry(dai, &(component)->dai_list, list)
> -#define for_each_component_dais_safe(component, dai, _dai)\
> - list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
> +#define for_each_component_dais(component, dai) \
> + for (dai = snd_soc_dai_from_list((component)->dai_list.next); \
> + snd_soc_dai_to_list(dai) != &(component)->dai_list; \
> + dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next))
> +
> +#define for_each_component_dais_safe(component, dai, _dai) \
> + for (dai = snd_soc_dai_from_list((component)->dai_list.next), \
> + _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next); \
> + snd_soc_dai_to_list(dai) != &(component)->dai_list; \
> + dai = _dai, _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(_dai)->next))
Hmm, I guess later on you will have to also encapsulate components, and
so this header macro won't be allowed to expose (component)->dai_list
either. You will need some function like:
struct list_head *component_dai_list(c) {
return &c->dai_list;
}
Then it will be kind of an explosion of function calls when
iterating:
#define for_each_component_dais(c, dai) \
for (dai = dai_from_list(component_dai_list(c)->next), \
dai_to_list(dai) != component_dai_list(c); \
dai = dai_from_list(dai_to_list(n)->next))
That's 4 calls per iteration I think. Idk if it really matters.
But if you find yourself repeating the pattern, maybe some generic
helper like this would be useful:
#define list_for_each_opaque(pos, head, from_list) \
for (struct list_head *_h = (head), *_i = _h->next; \
_i != _h && ((pos) = from_list(_i), true); \
_i = _i->next)
It's ugly only once, but more optimal (only 1 call to from_list per
iteration, and one call of component_dai_list() at the start).
Then you can do:
#define for_each_component_dais(c, dai) \
list_for_each_opaque(dai, component_dai_list(c), snd_soc_dai_from_list)
It's also fine this way though!
Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>
Kind regards,
Alvin
next prev parent reply other threads:[~2026-09-15 15:03 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
2026-09-14 1:43 ` [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id() Kuninori Morimoto
2026-09-15 13:43 ` Alvin Šipraga
2026-09-15 13:43 ` Alvin Šipraga
2026-09-15 13:43 ` Alvin Šipraga
2026-09-14 1:43 ` [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component() Kuninori Morimoto
2026-09-15 13:44 ` Alvin Šipraga
2026-09-14 1:43 ` [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver() Kuninori Morimoto
2026-09-15 13:44 ` Alvin Šipraga
2026-09-14 1:43 ` [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list() Kuninori Morimoto
2026-09-15 15:03 ` Alvin Šipraga [this message]
2026-09-15 23:37 ` Kuninori Morimoto
2026-09-14 1:45 ` [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params() Kuninori Morimoto
2026-09-15 1:51 ` Alvin Šipraga
2026-09-15 4:30 ` Kuninori Morimoto
2026-09-14 1:46 ` [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv() Kuninori Morimoto
2026-09-14 8:38 ` Charles Keepax
2026-09-15 15:05 ` Alvin Šipraga
2026-09-14 1:46 ` [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active() Kuninori Morimoto
2026-09-15 1:00 ` Alvin Šipraga
2026-09-15 5:20 ` Kuninori Morimoto
2026-09-15 13:42 ` Alvin Šipraga
2026-09-16 0:48 ` Kuninori Morimoto
2026-09-16 1:13 ` Alvin Šipraga
2026-09-16 1:45 ` Kuninori Morimoto
2026-09-14 1:46 ` [PATCH 08/10] ASoC: soc-dai: rename snd_soc_dai_action() Kuninori Morimoto
2026-09-14 1:46 ` [PATCH 09/10] ASoC: soc-dai: move snd_soc_dai_active_action() to soc-internal.h Kuninori Morimoto
2026-09-14 1:47 ` [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk() Kuninori Morimoto
2026-09-14 13:55 ` Mark Brown
2026-09-14 23:56 ` Kuninori Morimoto
2026-09-15 15:19 ` Alvin Šipraga
2026-09-15 23:38 ` Kuninori Morimoto
2026-09-14 13:37 ` [PATCH 00/10] ASoC: add new DAI functions Mark Brown
2026-09-15 0:05 ` Kuninori Morimoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aqlUINu_YUeN9O47@analog.com \
--to=alvin.sipraga@analog.com \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-sound@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.