[openwrt/openwrt] realtek: mdio: register mdio bus at controller node

LEDE Commits lede-commits at lists.infradead.org
Wed Jan 21 14:36:18 PST 2026


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/631e066bc3b58ed40ebdec1fdc8d2349c8074efe

commit 631e066bc3b58ed40ebdec1fdc8d2349c8074efe
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Mon Jan 12 17:20:39 2026 +0100

    realtek: mdio: register mdio bus at controller node
    
    In the future the mdio controller will have multiple busses
    defined in the dts below the controller node. Nevertheless
    it will still hand out only one single bus to the kernel.
    Attach the (exported) bus to the controller node instead of
    the single (dts) bus subnode.
    
    With this change the mdio lookup in the dsa driver must
    be changed to point to the mdio controller node too.
    
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/21438
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../files-6.12/drivers/net/dsa/rtl83xx/common.c    | 27 +++++++---------------
 .../drivers/net/mdio/mdio-realtek-otto.c           | 13 ++---------
 2 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
index 53e79bde82..373ab3728d 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
@@ -241,31 +241,22 @@ static int rtldsa_bus_c45_write(struct mii_bus *bus, int addr, int devad, int re
 
 static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
 {
-	struct device_node *dn, *phy_node, *pcs_node, *led_node, *np, *mii_np;
+	struct device_node *dn, *phy_node, *pcs_node, *led_node;
 	struct device *dev = priv->dev;
 	struct mii_bus *bus;
 	int ret;
 	u32 pn;
 
-	np = of_find_compatible_node(NULL, NULL, "realtek,otto-mdio");
-	if (!np) {
-		dev_err(priv->dev, "mdio controller node not found");
+	dn = of_find_compatible_node(NULL, NULL, "realtek,otto-mdio");
+	if (!dn)
 		return -ENODEV;
-	}
 
-	mii_np = of_get_child_by_name(np, "mdio-bus");
-	if (!mii_np) {
-		dev_err(priv->dev, "mdio-bus subnode not found");
-		return -ENODEV;
-	}
+	if (!of_device_is_available(dn))
+		ret = -ENODEV;
 
-	priv->parent_bus = of_mdio_find_bus(mii_np);
-	if (!priv->parent_bus) {
-		dev_dbg(priv->dev, "Deferring probe of mdio bus\n");
+	priv->parent_bus = of_mdio_find_bus(dn);
+	if (!priv->parent_bus)
 		return -EPROBE_DEFER;
-	}
-	if (!of_device_is_available(mii_np))
-		ret = -ENODEV;
 
 	bus = devm_mdiobus_alloc(priv->ds->dev);
 	if (!bus)
@@ -284,10 +275,8 @@ static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
 	priv->ds->user_mii_bus->priv = priv;
 
 	ret = mdiobus_register(priv->ds->user_mii_bus);
-	if (ret && mii_np) {
-		of_node_put(dn);
+	if (ret)
 		return ret;
-	}
 
 	dn = of_find_compatible_node(NULL, NULL, "realtek,rtl83xx-switch");
 	if (!dn) {
diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
index acaed57f3f..83fcb935a4 100644
--- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
+++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
@@ -1012,21 +1012,12 @@ static int rtmdio_reset(struct mii_bus *bus)
 
 static int rtmdio_probe(struct platform_device *pdev)
 {
-	struct device_node *dn, *mii_np;
+	struct device_node *dn;
 	struct device *dev = &pdev->dev;
 	struct rtmdio_bus_priv *priv;
 	struct mii_bus *bus;
 	u32 pn;
 
-	mii_np = of_get_child_by_name(dev->of_node, "mdio-bus");
-	if (!mii_np)
-		return -ENODEV;
-
-	if (!of_device_is_available(mii_np)) {
-		of_node_put(mii_np);
-		return -ENODEV;
-	}
-
 	bus = devm_mdiobus_alloc_size(dev, sizeof(*priv));
 	if (!bus)
 		return -ENOMEM;
@@ -1082,7 +1073,7 @@ static int rtmdio_probe(struct platform_device *pdev)
 
 	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev));
 
-	return devm_of_mdiobus_register(dev, bus, mii_np);
+	return devm_of_mdiobus_register(dev, bus, dev->of_node);
 }
 
 static const struct rtmdio_config rtmdio_838x_cfg = {




More information about the lede-commits mailing list