Commit c5286665 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: use of_for_each_phandle

The OF code provides a of_for_each_phandle() helper to iterate over
phandles. Use it instead of arbitrary iterating ourselves over the list
of phandles hanging to the "link" property of the port's device node.

The of_phandle_iterator_next() helper calls of_node_put() itself on
it.node. Thus We must only do it ourselves if we break the loop.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f163da88
...@@ -145,21 +145,18 @@ static int dsa_port_complete(struct dsa_switch_tree *dst, ...@@ -145,21 +145,18 @@ static int dsa_port_complete(struct dsa_switch_tree *dst,
struct dsa_port *port, struct dsa_port *port,
u32 src_port) u32 src_port)
{ {
struct device_node *link; struct device_node *dn = port->dn;
int index; struct of_phandle_iterator it;
struct dsa_switch *dst_ds; struct dsa_switch *dst_ds;
struct dsa_port *link_dp; struct dsa_port *link_dp;
int err;
for (index = 0;; index++) { of_for_each_phandle(&it, err, dn, "link", NULL, 0) {
link = of_parse_phandle(port->dn, "link", index); link_dp = dsa_tree_find_port_by_node(dst, it.node);
if (!link) if (!link_dp) {
break; of_node_put(it.node);
link_dp = dsa_tree_find_port_by_node(dst, link);
of_node_put(link);
if (!link_dp)
return 1; return 1;
}
dst_ds = link_dp->ds; dst_ds = link_dp->ds;
......
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