Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: lan966x: hardcode the number of external ports

Instead of counting the child nodes in the device tree, hardcode the
number of ports in the driver itself. The counting won't work at all
if an ethernet port is marked as disabled, e.g. because it is not
connected on the board at all.

It turns out that the LAN9662 and LAN9668 use the same switching IP
with the same synthesis parameters. The only difference is that the
output ports are not connected. Thus, we can just hardcode the
number of physical ports to 8.

Fixes: db8bcaad5393 ("net: lan966x: add the basic lan966x driver")
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20220704153654.1167886-1-michael@walle.cc
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Michael Walle and committed by
Jakub Kicinski
e6fa930f 26c12725

+3 -6
+2 -6
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
··· 994 994 struct fwnode_handle *ports, *portnp; 995 995 struct lan966x *lan966x; 996 996 u8 mac_addr[ETH_ALEN]; 997 - int err, i; 997 + int err; 998 998 999 999 lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL); 1000 1000 if (!lan966x) ··· 1025 1025 if (err) 1026 1026 return dev_err_probe(&pdev->dev, err, "Reset failed"); 1027 1027 1028 - i = 0; 1029 - fwnode_for_each_available_child_node(ports, portnp) 1030 - ++i; 1031 - 1032 - lan966x->num_phys_ports = i; 1028 + lan966x->num_phys_ports = NUM_PHYS_PORTS; 1033 1029 lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports, 1034 1030 sizeof(struct lan966x_port *), 1035 1031 GFP_KERNEL);
+1
drivers/net/ethernet/microchip/lan966x/lan966x_main.h
··· 34 34 /* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */ 35 35 #define QSYS_Q_RSRV 95 36 36 37 + #define NUM_PHYS_PORTS 8 37 38 #define CPU_PORT 8 38 39 39 40 /* Reserved PGIDs */