All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Jeremy Linton <jeremy.linton@arm.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH RFC 3/7] net: phy: clean up PHY ID reading
Date: Tue, 26 May 2020 16:46:55 +0100	[thread overview]
Message-ID: <20200526154655.GD1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <d73f2250-d89e-b79b-5ea1-dca4c0d22c4c@arm.com>

On Tue, May 26, 2020 at 10:38:31AM -0500, Jeremy Linton wrote:
> Hi,
> 
> On 5/26/20 9:31 AM, Russell King wrote:
> > Rearrange the code to read the PHY IDs, so we don't call get_phy_id()
> > only to immediately call get_phy_c45_ids().  Move that logic into
> > get_phy_device(), which results in better readability.
> > 
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> >   drivers/net/phy/phy_device.c | 25 +++++++++----------------
> >   1 file changed, 9 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index e04284c4ebf8..0d6b6ca66216 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -756,29 +756,18 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
> >   }
> >   /**
> > - * get_phy_id - reads the specified addr for its ID.
> > + * get_phy_c22_id - reads the specified addr for its clause 22 ID.
> >    * @bus: the target MII bus
> >    * @addr: PHY address on the MII bus
> >    * @phy_id: where to store the ID retrieved.
> > - * @is_c45: If true the PHY uses the 802.3 clause 45 protocol
> > - * @c45_ids: where to store the c45 ID information.
> > - *
> > - * Description: In the case of a 802.3-c22 PHY, reads the ID registers
> > - *   of the PHY at @addr on the @bus, stores it in @phy_id and returns
> > - *   zero on success.
> > - *
> > - *   In the case of a 802.3-c45 PHY, get_phy_c45_ids() is invoked, and
> > - *   its return value is in turn returned.
> >    *
> > + * Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus.
> > + * Return the PHY ID read from the PHY in @phy_id on successful access.
> >    */
> > -static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
> > -		      bool is_c45, struct phy_c45_device_ids *c45_ids)
> > +static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
> >   {
> >   	int phy_reg;
> > -	if (is_c45)
> > -		return get_phy_c45_ids(bus, addr, phy_id, c45_ids);
> > -
> >   	/* Grab the bits from PHYIR1, and put them in the upper half */
> >   	phy_reg = mdiobus_read(bus, addr, MII_PHYSID1);
> >   	if (phy_reg < 0) {
> > @@ -817,7 +806,11 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
> >   	c45_ids.devices_in_package = 0;
> >   	memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
> > -	r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
> > +	if (is_c45)
> > +		r = get_phy_c45_ids(bus, addr, &phy_id, &c45_ids);
> > +	else
> > +		r = get_phy_c22_id(bus, addr, &phy_id);
> > +
> >   	if (r)
> >   		return ERR_PTR(r);
> > 
> 
> I see this, and the c22 regs detection, but I don't see how your choosing to
> use the c22 regs if the 45's aren't responding. Which was one of the primary
> purposes of that other set.

You are entirely correct, but I am not aiming for that in this series.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC for 0.8m (est. 1762m) line in suburbia: sync at 13.1Mbps down 424kbps up

  reply	other threads:[~2020-05-26 15:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 14:29 [PATCH RFC 0/7] Clause 45 PHY probing cleanups Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 1/7] net: mdiobus: add clause 45 mdiobus accessors Russell King
2020-05-26 14:39   ` Andrew Lunn
2020-05-26 15:21     ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 2/7] net: phy: clean up cortina workaround Russell King
2020-05-26 14:31 ` [PATCH RFC 3/7] net: phy: clean up PHY ID reading Russell King
2020-05-26 15:38   ` Jeremy Linton
2020-05-26 15:46     ` Russell King - ARM Linux admin [this message]
2020-05-26 14:31 ` [PATCH RFC 4/7] net: phy: add support for probing MMDs >= 8 for devices-in-package Russell King
2020-05-26 17:14   ` Russell King - ARM Linux admin
2020-05-26 17:20     ` Jeremy Linton
2020-05-26 17:53       ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 5/7] net: phy: set devices_in_package only after validation Russell King
2020-05-26 15:39   ` Jeremy Linton
2020-05-26 15:50     ` Russell King - ARM Linux admin
2020-05-26 16:33       ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 6/7] net: phy: split devices_in_package Russell King
2020-05-26 15:39   ` Jeremy Linton
2020-05-26 15:47     ` Russell King - ARM Linux admin
2020-05-26 16:00       ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 7/7] net: phy: read MMD ID from all present MMDs Russell King
2020-05-26 15:35   ` Jeremy Linton
2020-05-26 15:46     ` Russell King - ARM Linux admin
2020-05-26 15:43 ` [PATCH RFC 0/7] Clause 45 PHY probing cleanups Russell King - ARM Linux admin

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=20200526154655.GD1551@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=jeremy.linton@arm.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.