diff --git a/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/common.c index 9d37cccabf4..d88a761209a 100644 --- a/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/common.c @@ -271,6 +271,20 @@ int write_phy(u32 port, u32 page, u32 reg, u32 val) return -1; } +static int rtldsa_mdio_read(struct mii_bus *bus, int addr, int regnum) +{ + struct rtl838x_switch_priv *priv = bus->priv; + + return mdiobus_read_nested(priv->parent_bus, addr, regnum); +} + +static int rtldsa_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val) +{ + struct rtl838x_switch_priv *priv = bus->priv; + + return mdiobus_write_nested(priv->parent_bus, addr, regnum, val); +} + static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) { struct device *dev = priv->dev; @@ -288,8 +302,8 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) return -ENODEV; } - priv->mii_bus = of_mdio_find_bus(mii_np); - if (!priv->mii_bus) { + priv->parent_bus = of_mdio_find_bus(mii_np); + if (!priv->parent_bus) { pr_debug("Deferring probe of mdio bus\n"); return -EPROBE_DEFER; } @@ -300,18 +314,14 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) if (!bus) return -ENOMEM; - bus->name = "rtl838x slave mii"; - - /* Since the NIC driver is loaded first, we can use the mdio rw functions - * assigned there. - */ - bus->read = priv->mii_bus->read; - bus->write = priv->mii_bus->write; + bus->name = "rtldsa_mdio"; + bus->read = rtldsa_mdio_read; + bus->write = rtldsa_mdio_write; snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", bus->name, dev->id); bus->parent = dev; priv->ds->slave_mii_bus = bus; - priv->ds->slave_mii_bus->priv = priv->mii_bus->priv; + priv->ds->slave_mii_bus->priv = priv; ret = mdiobus_register(priv->ds->slave_mii_bus); if (ret && mii_np) { diff --git a/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/rtl838x.h index 16c60983783..c721b4d0705 100644 --- a/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1081,7 +1081,7 @@ struct rtl838x_switch_priv { struct mutex pie_mutex; /* Mutex for Packet Inspection Engine */ int link_state_irq; int mirror_group_ports[4]; - struct mii_bus *mii_bus; + struct mii_bus *parent_bus; const struct rtl838x_reg *r; u8 cpu_port; u8 port_mask;