Skip to content

Commit cdb067d

Browse files
Rafał Miłeckidavem330
authored andcommitted
net: dsa: b53: Fix calculating number of switch ports
It isn't true that CPU port is always the last one. Switches BCM5301x have 9 ports (port 6 being inactive) and they use port 5 as CPU by default (depending on design some other may be CPU ports too). A more reliable way of determining number of ports is to check for the last set bit in the "enabled_ports" bitfield. This fixes b53 internal state, it will allow providing accurate info to the DSA and is required to fix BCM5301x support. Fixes: 967dd82 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Rafał Miłecki <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aabbdc6 commit cdb067d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,9 +2612,8 @@ static int b53_switch_init(struct b53_device *dev)
26122612
dev->cpu_port = 5;
26132613
}
26142614

2615-
/* cpu port is always last */
2616-
dev->num_ports = dev->cpu_port + 1;
26172615
dev->enabled_ports |= BIT(dev->cpu_port);
2616+
dev->num_ports = fls(dev->enabled_ports);
26182617

26192618
/* Include non standard CPU port built-in PHYs to be probed */
26202619
if (is539x(dev) || is531x5(dev)) {

0 commit comments

Comments
 (0)