From: Vivien Didelot Date: Mon, 21 Oct 2019 20:51:21 +0000 (-0400) Subject: net: dsa: use ports list to find a port by node X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=764b7e624284c3f41bdd15bd4e077d8ec5b8c686;p=linux.git net: dsa: use ports list to find a port by node Use the new ports list instead of iterating over switches and their ports to find a port from a given node. Signed-off-by: Vivien Didelot Reviewed-by: Florian Fainelli Signed-off-by: Jakub Kicinski --- diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 623805ba8e1ac..a4de7ff8b19bb 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -113,22 +113,11 @@ static bool dsa_port_is_user(struct dsa_port *dp) static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, struct device_node *dn) { - struct dsa_switch *ds; struct dsa_port *dp; - int device, port; - - for (device = 0; device < DSA_MAX_SWITCHES; device++) { - ds = dst->ds[device]; - if (!ds) - continue; - for (port = 0; port < ds->num_ports; port++) { - dp = &ds->ports[port]; - - if (dp->dn == dn) - return dp; - } - } + list_for_each_entry(dp, &dst->ports, list) + if (dp->dn == dn) + return dp; return NULL; }