Skip to content

Commit e6fa930

Browse files
mwallekuba-moo
authored andcommitted
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: db8bcaa ("net: lan966x: add the basic lan966x driver") Signed-off-by: Michael Walle <[email protected]> Reviewed-by: Horatiu Vultur <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 26c1272 commit e6fa930

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_main.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ static int lan966x_probe(struct platform_device *pdev)
994994
struct fwnode_handle *ports, *portnp;
995995
struct lan966x *lan966x;
996996
u8 mac_addr[ETH_ALEN];
997-
int err, i;
997+
int err;
998998

999999
lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL);
10001000
if (!lan966x)
@@ -1025,11 +1025,7 @@ static int lan966x_probe(struct platform_device *pdev)
10251025
if (err)
10261026
return dev_err_probe(&pdev->dev, err, "Reset failed");
10271027

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;
10331029
lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports,
10341030
sizeof(struct lan966x_port *),
10351031
GFP_KERNEL);

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
/* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */
3535
#define QSYS_Q_RSRV 95
3636

37+
#define NUM_PHYS_PORTS 8
3738
#define CPU_PORT 8
3839

3940
/* Reserved PGIDs */

0 commit comments

Comments
 (0)