From: Markus Stockhausen Date: Tue, 10 Feb 2026 11:55:15 +0000 (+0100) Subject: realtek: mdio: use bus auto registration X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e003062f7373d081532ae5d48e7c7c82c64d279;p=thirdparty%2Fopenwrt.git realtek: mdio: use bus auto registration Let the mdio bus autodetect the attached phys by providing a proper scan mask. Although this breaks the linkage to the DTS it is better than adding phys manually. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/21968 Signed-off-by: Robert Marko --- 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 e846c00b605..dc97176c930 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 @@ -177,7 +177,6 @@ struct rtmdio_ctrl { bool raw[RTMDIO_MAX_PORT]; int smi_bus[RTMDIO_MAX_PORT]; int smi_addr[RTMDIO_MAX_PORT]; - struct device_node *dn[RTMDIO_MAX_PORT]; bool smi_bus_isc45[RTMDIO_MAX_SMI_BUS]; }; @@ -931,6 +930,7 @@ static int rtmdio_probe(struct platform_device *pdev) struct rtmdio_ctrl *ctrl; struct device_node *dn; struct mii_bus *bus; + u64 mask = 0ULL; int ret, addr; bus = devm_mdiobus_alloc_size(dev, sizeof(*ctrl)); @@ -967,7 +967,7 @@ static int rtmdio_probe(struct platform_device *pdev) if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45")) ctrl->smi_bus_isc45[ctrl->smi_bus[addr]] = true; - ctrl->dn[addr] = dn; + mask |= BIT_ULL(addr); } bus->name = "Realtek MDIO bus"; @@ -977,7 +977,7 @@ static int rtmdio_probe(struct platform_device *pdev) bus->read_c45 = rtmdio_read_c45; bus->write_c45 = rtmdio_write_c45; bus->parent = dev; - bus->phy_mask = ~0; + bus->phy_mask = ~mask; snprintf(bus->id, MII_BUS_ID_SIZE, "realtek-mdio"); device_set_node(&bus->dev, of_fwnode_handle(dev->of_node)); @@ -988,14 +988,6 @@ static int rtmdio_probe(struct platform_device *pdev) if (ctrl->cfg->setup_polling) ctrl->cfg->setup_polling(bus); - for (addr = 0; addr < ctrl->cfg->cpu_port; addr++) { - if (ctrl->dn[addr]) { - ret = fwnode_mdiobus_register_phy(bus, of_fwnode_handle(ctrl->dn[addr]), addr); - if (ret) - return ret; - } - } - return 0; }