* [PATCH net v2] net: lan966x: hardcode the number of external ports
@ 2022-07-04 15:36 Michael Walle
2022-07-05 18:12 ` Horatiu Vultur
2022-07-06 1:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Michael Walle @ 2022-07-04 15:36 UTC (permalink / raw)
To: Horatiu Vultur, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Vladimir Oltean
Cc: netdev, linux-kernel, Michael Walle
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>
---
changes since v1:
- add fixes tag since the fix is simple
- switch from new specific compatible to "just use 8 for all"
drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 8 ++------
drivers/net/ethernet/microchip/lan966x/lan966x_main.h | 1 +
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 5784c4161e5e..1d6e3b641b2e 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -994,7 +994,7 @@ static int lan966x_probe(struct platform_device *pdev)
struct fwnode_handle *ports, *portnp;
struct lan966x *lan966x;
u8 mac_addr[ETH_ALEN];
- int err, i;
+ int err;
lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL);
if (!lan966x)
@@ -1025,11 +1025,7 @@ static int lan966x_probe(struct platform_device *pdev)
if (err)
return dev_err_probe(&pdev->dev, err, "Reset failed");
- i = 0;
- fwnode_for_each_available_child_node(ports, portnp)
- ++i;
-
- lan966x->num_phys_ports = i;
+ lan966x->num_phys_ports = NUM_PHYS_PORTS;
lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports,
sizeof(struct lan966x_port *),
GFP_KERNEL);
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
index 3b86ddddc756..2787055c1847 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
@@ -34,6 +34,7 @@
/* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */
#define QSYS_Q_RSRV 95
+#define NUM_PHYS_PORTS 8
#define CPU_PORT 8
/* Reserved PGIDs */
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] net: lan966x: hardcode the number of external ports
2022-07-04 15:36 [PATCH net v2] net: lan966x: hardcode the number of external ports Michael Walle
@ 2022-07-05 18:12 ` Horatiu Vultur
2022-07-06 1:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Horatiu Vultur @ 2022-07-05 18:12 UTC (permalink / raw)
To: Michael Walle
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Vladimir Oltean, netdev, linux-kernel
The 07/04/2022 17:36, Michael Walle wrote:
>
> 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>
> ---
> changes since v1:
> - add fixes tag since the fix is simple
> - switch from new specific compatible to "just use 8 for all"
>
> drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 8 ++------
> drivers/net/ethernet/microchip/lan966x/lan966x_main.h | 1 +
> 2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> index 5784c4161e5e..1d6e3b641b2e 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> @@ -994,7 +994,7 @@ static int lan966x_probe(struct platform_device *pdev)
> struct fwnode_handle *ports, *portnp;
> struct lan966x *lan966x;
> u8 mac_addr[ETH_ALEN];
> - int err, i;
> + int err;
>
> lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL);
> if (!lan966x)
> @@ -1025,11 +1025,7 @@ static int lan966x_probe(struct platform_device *pdev)
> if (err)
> return dev_err_probe(&pdev->dev, err, "Reset failed");
>
> - i = 0;
> - fwnode_for_each_available_child_node(ports, portnp)
> - ++i;
> -
> - lan966x->num_phys_ports = i;
> + lan966x->num_phys_ports = NUM_PHYS_PORTS;
> lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports,
> sizeof(struct lan966x_port *),
> GFP_KERNEL);
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
> index 3b86ddddc756..2787055c1847 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
> @@ -34,6 +34,7 @@
> /* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */
> #define QSYS_Q_RSRV 95
>
> +#define NUM_PHYS_PORTS 8
> #define CPU_PORT 8
>
> /* Reserved PGIDs */
> --
> 2.30.2
>
--
/Horatiu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] net: lan966x: hardcode the number of external ports
2022-07-04 15:36 [PATCH net v2] net: lan966x: hardcode the number of external ports Michael Walle
2022-07-05 18:12 ` Horatiu Vultur
@ 2022-07-06 1:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-06 1:30 UTC (permalink / raw)
To: Michael Walle
Cc: horatiu.vultur, davem, edumazet, kuba, pabeni, olteanv, netdev,
linux-kernel
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 4 Jul 2022 17:36:54 +0200 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net,v2] net: lan966x: hardcode the number of external ports
https://git.kernel.org/netdev/net/c/e6fa930f73a1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-06 1:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-04 15:36 [PATCH net v2] net: lan966x: hardcode the number of external ports Michael Walle
2022-07-05 18:12 ` Horatiu Vultur
2022-07-06 1:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox