]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: mv88e6xxx: iterate using dsa_switch_for_each_user_port in mv88e6xxx_port_ch...
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 6 Dec 2021 16:57:50 +0000 (18:57 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Dec 2021 22:31:15 +0000 (14:31 -0800)
commit7efca2f8721b6c3c55666b7496b5099c8b904ff2
treefae6781b5ac52fe65fad112133c58cc208cd45a4
parent0210dab7b26c4bc54ffa1abd8adaab086e67c5d2
net: dsa: mv88e6xxx: iterate using dsa_switch_for_each_user_port in mv88e6xxx_port_check_hw_vlan

Avoid a plethora of dsa_to_port() calls (some hidden behind
dsa_is_*_port and some in plain sight) by keeping two struct dsa_port
references: one to the port passed as argument, and another to the other
ports of the switch that we're iterating over.

This isn't called from the DSA initialization path, so there is no risk
that we have user ports without a dp->slave populated. So the combined
checks that a port isn't a DSA port, a CPU port, or doesn't have a slave
net device (therefore is unused), are strictly equivalent to the simple
check that the port is a user port. This is already handled by the DSA
iterator.

i gets replaced by other_dp->index, dsa_is_*_port calls get replaced by
dsa_port_is_*, and dsa_to_port gets replaced by the respective pointer
directly.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/mv88e6xxx/chip.c