net: dsa: mt7530: factor out bridge join/leave logic
authorMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 18 Jun 2024 07:17:12 +0000 (09:17 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Jun 2024 12:10:01 +0000 (13:10 +0100)
commitc25c961fc7f36682f0a530150f1b7453ebc344cd
treedbb47d6551f8535c5da6b7b9956eae480f5d5d9d
parent65e4efa049781519e376e6a9bd8517643fd1e858
net: dsa: mt7530: factor out bridge join/leave logic

As preparation for implementing bridge port isolation, move the logic to
add and remove bits in the port matrix into a new helper
mt7530_update_port_member(), which is called from
mt7530_port_bridge_join() and mt7530_port_bridge_leave().

Another part of the preparation is using dsa_port_offloads_bridge_dev()
instead of dsa_port_offloads_bridge() to check for bridge membership, as
we don't have a struct dsa_bridge in mt7530_port_bridge_flags().

The port matrix setting is slightly streamlined, now always first setting
the mt7530_port's pm field and then writing the port matrix from that
field into the hardware register, instead of duplicating the bit
manipulation for both the struct field and the register.

mt7530_port_bridge_join() was previously using |= to update the port
matrix with the port bitmap, which was unnecessary, as pm would only
have the CPU port set before joining a bridge; a simple assignment can
be used for both joining and leaving (and will also work when individual
bits are added/removed in port_bitmap with regard to the previous port
matrix, which is what happens with port isolation).

No functional change intended.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mt7530.c