Skip to content

Commit

Permalink
ASoC: simple-card-utils: check "reg" property on asoc_simple_card_get…
Browse files Browse the repository at this point in the history
…_dai_id()

[ Upstream commit a0c426f ]

We will get DAI ID from "reg" property if it has on DT, otherwise get
it by counting port/endpoint.

But in below case, we need to get DAI ID = 0 via port reg = <0>, but
current implementation returns ID = 1, because it can't judge ID = 0 was
from "non reg" or "reg = <0>".
Thus, it will count port/endpoint number as "non reg" case.

of_graph_parse_endpoint() implementation itself is not a problem,
but because asoc_simple_card_get_dai_id() need to count port/endpoint
number when "non reg" case, it need to know ID = 0 was from
"non reg" or "reg = <0>".
This patch fix this issue.

	port {
		reg = <0>;
		xxxx: endpoint@0 {
		};
=>		xxxx: endpoint@1 {
		};
	};

Signed-off-by: Kuninori Morimoto <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
morimoto authored and gregkh committed Apr 5, 2019
1 parent 45040e9 commit 0a2e1a5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sound/soc/generic/simple-card-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,20 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep)
/* use endpoint/port reg if exist */
ret = of_graph_parse_endpoint(ep, &info);
if (ret == 0) {
if (info.id)
/*
* Because it will count port/endpoint if it doesn't have "reg".
* But, we can't judge whether it has "no reg", or "reg = <0>"
* only of_graph_parse_endpoint().
* We need to check "reg" property
*/
if (of_get_property(ep, "reg", NULL))
return info.id;
if (info.port)

node = of_get_parent(ep);
of_node_put(node);
if (of_get_property(node, "reg", NULL))
return info.port;
}

node = of_graph_get_port_parent(ep);

/*
Expand Down

0 comments on commit 0a2e1a5

Please sign in to comment.