summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
diff options
context:
space:
mode:
authorRobert Hancock <hancock@sedsystems.ca>2019-06-07 00:28:21 +0200
committerDavid S. Miller <davem@davemloft.net>2019-06-07 01:24:30 +0200
commit3b09a3fb35079106fd490241bdc8e0c31434be00 (patch)
treea1f91969abac175ab34a16577414a37bebf6f076 /drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
parentnet: axienet: document device tree mdio child node (diff)
downloadlinux-3b09a3fb35079106fd490241bdc8e0c31434be00.tar.xz
linux-3b09a3fb35079106fd490241bdc8e0c31434be00.zip
net: axienet: Fix MDIO bus parent node detection
This driver was previously using the parent node of the specified PHY node as the device node to register the MDIO bus on. Andrew Lunn pointed out this is wrong as the PHY node is potentially not even underneath the MDIO bus for the current device instance. Find the MDIO node explicitly by looking it up by name under the controller's device node instead. This could potentially break existing device trees if they don't use "mdio" as the name for the MDIO bus, but I did not find any with various searches and Xilinx's examples all use mdio as the name so it seems like this should be relatively safe. Signed-off-by: Robert Hancock <hancock@sedsystems.ca> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c')
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
index 7106810793d5..435ed308d990 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
@@ -228,7 +228,6 @@ int axienet_mdio_setup(struct axienet_local *lp)
if (!bus)
return -ENOMEM;
- mdio_node = of_get_parent(lp->phy_node);
snprintf(bus->id, MII_BUS_ID_SIZE, "axienet-%.8llx",
(unsigned long long)lp->regs_start);
@@ -239,7 +238,9 @@ int axienet_mdio_setup(struct axienet_local *lp)
bus->parent = lp->dev;
lp->mii_bus = bus;
+ mdio_node = of_get_child_by_name(lp->dev->of_node, "mdio");
ret = of_mdiobus_register(bus, mdio_node);
+ of_node_put(mdio_node);
if (ret) {
mdiobus_free(bus);
lp->mii_bus = NULL;