From: Markus Stockhausen Date: Mon, 12 Jan 2026 16:20:39 +0000 (+0100) Subject: realtek: mdio: register mdio bus at controller node X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=631e066bc3b58ed40ebdec1fdc8d2349c8074efe;p=thirdparty%2Fopenwrt.git 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 Link: https://github.com/openwrt/openwrt/pull/21438 Signed-off-by: Hauke Mehrtens --- 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 53e79bde822..373ab3728d2 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 acaed57f3fe..83fcb935a40 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 = {