Skip to content

Commit c0b7362

Browse files
vivienJakub Kicinski
authored andcommitted
net: dsa: use ports list to find first CPU port
Use the new ports list instead of iterating over switches and their ports when looking up the first CPU port in the tree. Signed-off-by: Vivien Didelot <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0cfec58 commit c0b7362

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

net/dsa/dsa2.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,11 @@ static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst)
186186

187187
static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst)
188188
{
189-
struct dsa_switch *ds;
190189
struct dsa_port *dp;
191-
int device, port;
192-
193-
for (device = 0; device < DSA_MAX_SWITCHES; device++) {
194-
ds = dst->ds[device];
195-
if (!ds)
196-
continue;
197190

198-
for (port = 0; port < ds->num_ports; port++) {
199-
dp = &ds->ports[port];
200-
201-
if (dsa_port_is_cpu(dp))
202-
return dp;
203-
}
204-
}
191+
list_for_each_entry(dp, &dst->ports, list)
192+
if (dsa_port_is_cpu(dp))
193+
return dp;
205194

206195
return NULL;
207196
}

0 commit comments

Comments
 (0)