Skip to content

Commit

Permalink
net: dsa: microchip: Fix probing KSZ87xx switch with DT node for host…
Browse files Browse the repository at this point in the history
… 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 <[email protected]>
Cc: Microchip Linux Driver Support <[email protected]>
Cc: Michael Grzeschik <[email protected]>
Cc: Marek Vasut <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bwh-mind authored and gregkh committed Aug 18, 2021
1 parent 3dc5666 commit f365d53
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/dsa/microchip/ksz_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,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->mib_port_cnt)
return -EINVAL;
of_get_phy_mode(port,
&dev->ports[port_num].interface);
Expand Down

0 comments on commit f365d53

Please sign in to comment.