[PATCH RFC 01/15] of: property: add port base loop

Rob Herring robh+dt at kernel.org
Tue Jun 22 16:31:14 CEST 2021


On Mon, Jun 21, 2021 at 7:14 PM Kuninori Morimoto
<kuninori.morimoto.gx at renesas.com> wrote:
>
>
> From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
>
> We have endpoint base functions
>         - of_graph_get_next_endpoint()
>         - of_graph_get_endpoint_count()
>         - for_each_endpoint_of_node()
>
> for_each_endpoint_of_node() loop finds endpoint.
>
>         ports {
>                 port at 0 {
> (1)                     endpoint {...};
>                 };
>                 port at 1 {
> (2)                     endpoint {...};
>                 };
>                 ...
>         };
>
> In above case, for_each_endpoint_of_node() loop
> finds endpoint as (1) -> (2) -> ...

Wanting to iterate endpoints across ports like that is odd given the
ports represent different things. I think you will find there aren't
too many users as I tried to get rid of most of them some time ago.
(I'm sure more have slipped in)

> If we want to get port at 0 -> port at 1 -> ...
> instead of endpoint, we need do like below
>
>         for_each_endpoint_of_node(node, endpoint) {
>                 port = of_get_parent(endpoint);
>                 ...
>         }
>
> But port might have multi endpoints.
>
>         ports {
>                 port at 0 {
> (1)                     endpoint at 0 {...};
> (2)                     endpoint at 1 {...};
>                 };
>                 port at 1 {
> (3)                     endpoint {...};
>                 };
>                 ...
>         };
>
> In such case, people want to have "port base" loop
> instead of "endpoints base" loop.
> This patch adds such functions/macros.

As bindings should be defining what each port number represents, I
don't think iterating thru them without regard to port numbers is the
right model. Drivers should be requesting specific port numbers.

Rob


More information about the Alsa-devel mailing list