net: dsa: microchip: Fix probing KSZ87xx switch with DT node for host port
authorBen Hutchings <ben.hutchings@mind.be>
Mon, 16 Aug 2021 18:09:09 +0000 (20:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Aug 2021 06:59:19 +0000 (08:59 +0200)
commitf365d53c868725c472d515fa1ce4f57d0eaff5ae
treea33a7e856eb9f66dcd0789966aed629ade7c52fe
parent3dc5666baf2a135f250e4101d41d5959ac2c2e1f
net: dsa: microchip: Fix probing KSZ87xx switch with DT node for host port

The ksz8795 and ksz9477 drivers differ in the way they count ports.
For ksz8795, ksz_device::port_cnt does not include the host port
whereas for ksz9477 it does.  This inconsistency was fixed in Linux
5.11 by a series of changes, but remains in 5.10-stable.

When probing, the common code treats a port device node with an
address >= dev->port_cnt as a fatal error.  As a minimal fix, change
it to compare again dev->mib_port_cnt.  This is the length of the
dev->ports array that the port number will be used to index, and
always includes the host port.

Cc: Woojung Huh <woojung.huh@microchip.com>
Cc: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/microchip/ksz_common.c