Commit e328ab3d authored by Mark Brown's avatar Mark Brown

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.
parents 77e6a5e4 815f1fcf
......@@ -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;
}
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment