mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Michael Klein <michael@fossekall.de>,
	Aleksander Jan Bajkowski <olek2@wp.pl>,
	Bevan Weiss <bevan.weiss@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/4] net: phy: realtek: use paged access for MDIO_MMD_VEND2 in C22 mode
Date: Sun, 4 Jan 2026 22:02:28 +0000	[thread overview]
Message-ID: <aVrjdEVYCag4yKxg@makrotopia.org> (raw)
In-Reply-To: <aVraNHPA3IzsEF9R@shell.armlinux.org.uk>

On Sun, Jan 04, 2026 at 09:23:00PM +0000, Russell King (Oracle) wrote:
> 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);

Even this would be possible then:
	if (devnum != MDIO_MMD_VEND2 || phydev->is_c45)
		return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr,
				    phydev->is_c45, devnum, regad);

> 
> 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.

I also thought it'd be good to do that, but that would require moving
the function prototypes from drivers/net/phy/phylib-internal.h to a
public header which the PHY driver may include, eg. phylib.h. (I suppose
that 'phylib-internal.h' should not be included in PHY drivers).

Needless to say that I also don't fancy open-coding unlocked variants
of phy_{read,write}_paged, but that's on a other story...

  reply	other threads:[~2026-01-04 22:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-04 13:11 [PATCH net-next 0/4] net: phy: realtek: various improvements for 2.5GE PHYs Daniel Golle
2026-01-04 13:11 ` [PATCH net-next 1/4] net: phy: realtek: fix whitespace in struct phy_driver initializers Daniel Golle
2026-01-04 13:11 ` [PATCH net-next 2/4] net: phy: realtek: implement configuring in-band an Daniel Golle
2026-01-04 13:12 ` [PATCH net-next 3/4] net: phy: realtek: use paged access for MDIO_MMD_VEND2 in C22 mode Daniel Golle
2026-01-04 14:30   ` ALOK TIWARI
2026-01-04 21:23   ` Russell King (Oracle)
2026-01-04 22:02     ` Daniel Golle [this message]
2026-01-04 22:38   ` kernel test robot
2026-01-05  0:52   ` kernel test robot
2026-01-04 13:12 ` [PATCH net-next 4/4] net: phy: realtek: get rid of magic number in rtlgen_read_status() Daniel Golle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aVrjdEVYCag4yKxg@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=andrew@lunn.ch \
    --cc=bevan.weiss@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michael@fossekall.de \
    --cc=netdev@vger.kernel.org \
    --cc=olek2@wp.pl \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®