Skip to content

Commit d12e1c4

Browse files
Rafał Miłeckidavem330
authored andcommitted
net: dsa: b53: Set correct number of ports in the DSA struct
Setting DSA_MAX_PORTS caused DSA to call b53 callbacks (e.g. b53_disable_port() during dsa_register_switch()) for invalid (non-existent) ports. That made b53 modify unrelated registers and is one of reasons for a broken BCM5301x support. This problem exists for years but DSA_MAX_PORTS usage has changed few times. It seems the most accurate to reference commit dropping dsa_switch_alloc() in the Fixes tag. Fixes: 7e99e34 ("net: dsa: remove dsa_switch_alloc helper") Signed-off-by: Rafał Miłecki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cdb067d commit d12e1c4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,8 @@ static int b53_switch_init(struct b53_device *dev)
26152615
dev->enabled_ports |= BIT(dev->cpu_port);
26162616
dev->num_ports = fls(dev->enabled_ports);
26172617

2618+
dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS);
2619+
26182620
/* Include non standard CPU port built-in PHYs to be probed */
26192621
if (is539x(dev) || is531x5(dev)) {
26202622
for (i = 0; i < dev->num_ports; i++) {
@@ -2659,7 +2661,6 @@ struct b53_device *b53_switch_alloc(struct device *base,
26592661
return NULL;
26602662

26612663
ds->dev = base;
2662-
ds->num_ports = DSA_MAX_PORTS;
26632664

26642665
dev = devm_kzalloc(base, sizeof(*dev), GFP_KERNEL);
26652666
if (!dev)

0 commit comments

Comments
 (0)