Skip to content

Commit 33ab04a

Browse files
mwallegregkh
authored andcommitted
net: lan966x: hardcode the number of external ports
commit e6fa930 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent df049da commit 33ab04a

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
@@ -979,7 +979,7 @@ static int lan966x_probe(struct platform_device *pdev)
979979
struct fwnode_handle *ports, *portnp;
980980
struct lan966x *lan966x;
981981
u8 mac_addr[ETH_ALEN];
982-
int err, i;
982+
int err;
983983

984984
lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL);
985985
if (!lan966x)
@@ -1010,11 +1010,7 @@ static int lan966x_probe(struct platform_device *pdev)
10101010
if (err)
10111011
return dev_err_probe(&pdev->dev, err, "Reset failed");
10121012

1013-
i = 0;
1014-
fwnode_for_each_available_child_node(ports, portnp)
1015-
++i;
1016-
1017-
lan966x->num_phys_ports = i;
1013+
lan966x->num_phys_ports = NUM_PHYS_PORTS;
10181014
lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports,
10191015
sizeof(struct lan966x_port *),
10201016
GFP_KERNEL);

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

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

34+
#define NUM_PHYS_PORTS 8
3435
#define CPU_PORT 8
3536

3637
/* Reserved PGIDs */

0 commit comments

Comments
 (0)