Commit e6fa930f authored by Michael Walle's avatar Michael Walle Committed by Jakub Kicinski

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: db8bcaad ("net: lan966x: add the basic lan966x driver")
Signed-off-by: default avatarMichael Walle <michael@walle.cc>
Reviewed-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20220704153654.1167886-1-michael@walle.ccSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 26c12725
...@@ -994,7 +994,7 @@ static int lan966x_probe(struct platform_device *pdev) ...@@ -994,7 +994,7 @@ static int lan966x_probe(struct platform_device *pdev)
struct fwnode_handle *ports, *portnp; struct fwnode_handle *ports, *portnp;
struct lan966x *lan966x; struct lan966x *lan966x;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
int err, i; int err;
lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL); lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL);
if (!lan966x) if (!lan966x)
...@@ -1025,11 +1025,7 @@ static int lan966x_probe(struct platform_device *pdev) ...@@ -1025,11 +1025,7 @@ static int lan966x_probe(struct platform_device *pdev)
if (err) if (err)
return dev_err_probe(&pdev->dev, err, "Reset failed"); return dev_err_probe(&pdev->dev, err, "Reset failed");
i = 0; lan966x->num_phys_ports = NUM_PHYS_PORTS;
fwnode_for_each_available_child_node(ports, portnp)
++i;
lan966x->num_phys_ports = i;
lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports, lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports,
sizeof(struct lan966x_port *), sizeof(struct lan966x_port *),
GFP_KERNEL); GFP_KERNEL);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
/* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */ /* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */
#define QSYS_Q_RSRV 95 #define QSYS_Q_RSRV 95
#define NUM_PHYS_PORTS 8
#define CPU_PORT 8 #define CPU_PORT 8
/* Reserved PGIDs */ /* Reserved PGIDs */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment