OSDN Git Service

net: dsa: use ports list in dsa_to_port
authorVivien Didelot <vivien.didelot@gmail.com>
Mon, 21 Oct 2019 20:51:17 +0000 (16:51 -0400)
committerJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 22 Oct 2019 19:37:06 +0000 (12:37 -0700)
Use the new ports list instead of accessing the dsa_switch array
of ports in the dsa_to_port helper.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
include/net/dsa.h

index 6ff6dfc..d2b7ee2 100644 (file)
@@ -285,7 +285,14 @@ struct dsa_switch {
 
 static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
 {
-       return &ds->ports[p];
+       struct dsa_switch_tree *dst = ds->dst;
+       struct dsa_port *dp = NULL;
+
+       list_for_each_entry(dp, &dst->ports, list)
+               if (dp->ds == ds && dp->index == p)
+                       break;
+
+       return dp;
 }
 
 static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)