Re: [PATCH net-next 3/4] net: phy: realtek: use paged access for MDIO_MMD_VEND2 in C22 mode

From: Russell King (Oracle)
Date: Sun Jan 04 2026 - 16:23:36 EST


On Sun, Jan 04, 2026 at 01:12:13PM +0000, Daniel Golle wrote:
> +static int rtl822xb_read_mmd(struct phy_device *phydev, int devnum, u16 reg)
> +{
> + int oldpage, ret, read_ret;
> + u16 page;
> +
> + /* Use Clause-45 bus access in case it is available */
> + if (phydev->is_c45)
> + return __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr,
> + devnum, mmdreg);
> +
> + /* Use indirect access via MII_MMD_CTRL and MII_MMD_DATA for all
> + * MMDs except MDIO_MMD_VEND2
> + */
> + if (devnum != MDIO_MMD_VEND2) {
> + __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
> + MII_MMD_CTRL, devnum);
> + __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
> + MII_MMD_DATA, mmdreg);
> + __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
> + MII_MMD_CTRL, devnum | MII_MMD_CTRL_NOINCR);
> +
> + return __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr,
> + MII_MMD_DATA);
> + }

I think I'd prefer this structure:

if (devnum != MDIO_MMD_VEND2)
return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr,
phydev->is_c45, devnum, regad);

if (phydev->is_c45)
return __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr,
devnum, mmdreg);

rather than open-coding the indirect access, or the reverse order with
mmd_phy_read() called with is_c45 set to false.

Same for the write function.

Thanks.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!