[PATCH net v1 1/2] net: dsa: microchip: fix devicetree parsing of cpu node

From: Sven Van Asbroeck
Date: Sat Dec 05 2020 - 13:33:01 EST


From: Sven Van Asbroeck <thesven73@xxxxxxxxx>

On the ksz8795, if the devicetree contains a cpu node,
devicetree parsing fails and the whole driver errors out.

Fix the devicetree parsing code by making it use the
correct number of ports.

Fixes: 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")
Tested-by: Sven Van Asbroeck <thesven73@xxxxxxxxx> # ksz8795
Signed-off-by: Sven Van Asbroeck <thesven73@xxxxxxxxx>
---

Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git # 905b2032fa42

To: Woojung Huh <woojung.huh@xxxxxxxxxxxxx>
To: Microchip Linux Driver Support <UNGLinuxDriver@xxxxxxxxxxxxx>
To: Andrew Lunn <andrew@xxxxxxx>
To: Vivien Didelot <vivien.didelot@xxxxxxxxx>
To: Florian Fainelli <f.fainelli@xxxxxxxxx>
To: Vladimir Oltean <olteanv@xxxxxxxxx>
To: "David S. Miller" <davem@xxxxxxxxxxxxx>
To: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Helmut Grohne <helmut.grohne@xxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx

drivers/net/dsa/microchip/ksz_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index e5f047129b15..17b804c44c53 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -431,7 +431,7 @@ int ksz_switch_register(struct ksz_device *dev,
if (of_property_read_u32(port, "reg",
&port_num))
continue;
- if (port_num >= dev->port_cnt)
+ if (port_num >= dev->ds->num_ports)
return -EINVAL;
of_get_phy_mode(port,
&dev->ports[port_num].interface);
--
2.17.1