summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-11-06 16:11:50 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-09 09:26:49 +0900
commitc52866655558e5fc87ceae8aac528a7e410c8a77 (patch)
treead5e495febf1bc80007289a8becadfd98ce81436 /net
parentf163da8853aa9d8060157a96ed314299b87ba070 (diff)
downloadlwn-c52866655558e5fc87ceae8aac528a7e410c8a77.tar.gz
lwn-c52866655558e5fc87ceae8aac528a7e410c8a77.zip
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: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dsa/dsa2.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 0f6f8c1701f9..25ed41262ead 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -145,21 +145,18 @@ static int dsa_port_complete(struct dsa_switch_tree *dst,
struct dsa_port *port,
u32 src_port)
{
- struct device_node *link;
- int index;
+ struct device_node *dn = port->dn;
+ struct of_phandle_iterator it;
struct dsa_switch *dst_ds;
struct dsa_port *link_dp;
+ int err;
- for (index = 0;; index++) {
- link = of_parse_phandle(port->dn, "link", index);
- if (!link)
- break;
-
- link_dp = dsa_tree_find_port_by_node(dst, link);
- of_node_put(link);
-
- if (!link_dp)
+ of_for_each_phandle(&it, err, dn, "link", NULL, 0) {
+ link_dp = dsa_tree_find_port_by_node(dst, it.node);
+ if (!link_dp) {
+ of_node_put(it.node);
return 1;
+ }
dst_ds = link_dp->ds;