[PATCH 7/8] net: phy: fix miibus parent device of_node not matching phy node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The device node of a miibus parent device usually points to the ethernet
device node whereas the parent device node of a phy device usually
points to the mdio {} subnode between the ethernet node and the phy
node, so both can't match. Ethernet drivers usually provide a pointer
to the mdio {} subnode in miibus::dev.of_node, so use that to match
against the phy nodes parent.

This occured on a TQMa6UL where two FECs are registered, but both phys
are connected to the FEC2.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/net/phy/mdio_bus.c | 10 +++-------
 drivers/net/phy/phy.c      |  2 +-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 94123ef614..eed7c779e7 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -316,19 +316,15 @@ int mdiobus_register(struct mii_bus *bus)
 
 	pr_info("%s: probed\n", dev_name(&bus->dev));
 
+	if (!bus->dev.of_node)
+		bus->dev.of_node = bus->parent->of_node;
+
 	if (bus->dev.of_node) {
 		bus->dev.of_node->dev = &bus->dev;
 
 		/* Register PHY's as child node to mdio node */
 		of_mdiobus_register(bus, bus->dev.of_node);
 	}
-	else if (bus->parent->of_node) {
-		/*
-		 * Register PHY's as child node to the ethernet node,
-		 * if there was no mdio node
-		 */
-		of_mdiobus_register(bus, bus->parent->of_node);
-	}
 
 	return 0;
 }
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index ad02732ff9..abd78b2c80 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -358,7 +358,7 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
 	if (!of_property_read_u32(phy_node, "reg", &addr)) {
 		of_device_ensure_probed(phy_node->parent);
 		for_each_mii_bus(bus) {
-			if (bus->parent->of_node == phy_node->parent) {
+			if (bus->dev.of_node == phy_node->parent) {
 				struct phy_device *phy = mdiobus_scan(bus, addr);
 				if (!IS_ERR(phy))
 					return phy;
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux