Commit 764b7e62 authored by Vivien Didelot's avatar Vivien Didelot Committed by Jakub Kicinski
Browse files

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: default avatarVivien Didelot <vivien.didelot@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent 86bfb2c1
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -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];

	list_for_each_entry(dp, &dst->ports, list)
		if (dp->dn == dn)
			return dp;
		}
	}

	return NULL;
}