lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aVraNHPA3IzsEF9R@shell.armlinux.org.uk>
Date: Sun, 4 Jan 2026 21:23:00 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Daniel Golle <daniel@...rotopia.org>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Vladimir Oltean <vladimir.oltean@....com>,
	Michael Klein <michael@...sekall.de>,
	Aleksander Jan Bajkowski <olek2@...pl>,
	Bevan Weiss <bevan.weiss@...il.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 3/4] net: phy: realtek: use paged access for
 MDIO_MMD_VEND2 in C22 mode

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!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ