aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
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-08 19:26:49 -0500
commitc52866655558e5fc87ceae8aac528a7e410c8a77 (patch)
treead5e495febf1bc80007289a8becadfd98ce81436 /net/dsa
parentf163da8853aa9d8060157a96ed314299b87ba070 (diff)
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/dsa')
-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,
145 struct dsa_port *port, 145 struct dsa_port *port,
146 u32 src_port) 146 u32 src_port)
147{ 147{
148 struct device_node *link; 148 struct device_node *dn = port->dn;
149 int index; 149 struct of_phandle_iterator it;
150 struct dsa_switch *dst_ds; 150 struct dsa_switch *dst_ds;
151 struct dsa_port *link_dp; 151 struct dsa_port *link_dp;
152 int err;
152 153
153 for (index = 0;; index++) { 154 of_for_each_phandle(&it, err, dn, "link", NULL, 0) {
154 link = of_parse_phandle(port->dn, "link", index); 155 link_dp = dsa_tree_find_port_by_node(dst, it.node);
155 if (!link) 156 if (!link_dp) {
156 break; 157 of_node_put(it.node);
157
158 link_dp = dsa_tree_find_port_by_node(dst, link);
159 of_node_put(link);
160
161 if (!link_dp)
162 return 1; 158 return 1;
159 }
163 160
164 dst_ds = link_dp->ds; 161 dst_ds = link_dp->ds;
165 162