diff options
author | Mark Brown <broonie@kernel.org> | 2024-09-04 20:09:26 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-09-04 20:09:26 +0100 |
commit | e328ab3de4d8147e2458a524db0f7661e7c28ac7 (patch) | |
tree | 4f0f6b64ab4b7f2a55f7694a2c701bfd8d9cff41 | |
parent | 77e6a5e40aa393492cf3f1d2623d7d1dff7f33de (diff) | |
parent | 815f1fcf2403454904cbbc5cf370df6bc300f392 (diff) |
Some clean up with helper fucntion
Merge series from Zhang Zekun <zhangzekun11@huawei.com>:
There are some helper functions which can be used to simplify the code.
So, let's use these functions to make code more simple.
-rw-r--r-- | sound/soc/generic/audio-graph-card.c | 12 | ||||
-rw-r--r-- | sound/soc/generic/audio-graph-card2.c | 11 |
2 files changed, 3 insertions, 20 deletions
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 1bdcfc4d4222..03add80e75f3 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -361,7 +361,6 @@ static int __graph_for_each_link(struct simple_util_priv *priv, struct device *dev = simple_priv_to_dev(priv); struct device_node *node = dev->of_node; struct device_node *cpu_port; - struct device_node *cpu_ep; struct device_node *codec_ep; struct device_node *codec_port; struct device_node *codec_port_old = NULL; @@ -371,14 +370,9 @@ static int __graph_for_each_link(struct simple_util_priv *priv, /* loop for all listed CPU port */ of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { cpu_port = it.node; - cpu_ep = NULL; /* loop for all CPU endpoint */ - while (1) { - cpu_ep = of_get_next_child(cpu_port, cpu_ep); - if (!cpu_ep) - break; - + for_each_child_of_node_scoped(cpu_port, cpu_ep) { /* get codec */ codec_ep = of_graph_get_remote_endpoint(cpu_ep); codec_port = ep_to_port(codec_ep); @@ -408,10 +402,8 @@ static int __graph_for_each_link(struct simple_util_priv *priv, of_node_put(codec_ep); of_node_put(codec_port); - if (ret < 0) { - of_node_put(cpu_ep); + if (ret < 0) return ret; - } codec_port_old = codec_port; } diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 051adb567397..bf4c1ab4ec58 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1139,21 +1139,12 @@ static int graph_counter(struct device_node *lnk) */ if (graph_lnk_is_multi(lnk)) { struct device_node *ports = port_to_ports(lnk); - struct device_node *port = NULL; - int cnt = 0; /* * CPU/Codec = N:M case has many endpoints. * We can't use of_graph_get_endpoint_count() here */ - while(1) { - port = of_get_next_child(ports, port); - if (!port) - break; - cnt++; - } - - return cnt - 1; + return of_get_child_count(ports) - 1; } /* * Single CPU / Codec |