All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	David Epping <david.epping@missinglinkelectronics.com>,
	Harini Katakam <harini.katakam@amd.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH 1/3] net: phy: extend PHY package API to support multiple global address
Date: Sun, 26 Nov 2023 19:07:32 +0100	[thread overview]
Message-ID: <65638967.5d0a0220.28475.43b3@mx.google.com> (raw)
In-Reply-To: <cc37984c-13b1-4116-99f8-1a65546c477a@lunn.ch>

On Sun, Nov 26, 2023 at 07:04:26PM +0100, Andrew Lunn wrote:
> > @@ -1648,20 +1648,27 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_10g);
> >  /**
> >   * phy_package_join - join a common PHY group
> >   * @phydev: target phy_device struct
> > - * @addr: cookie and PHY address for global register access
> > + * @base_addr: cookie and base PHY address of PHY package for offset
> > + *   calculation of global register access
> >   * @priv_size: if non-zero allocate this amount of bytes for private data
> >   *
> >   * This joins a PHY group and provides a shared storage for all phydevs in
> >   * this group. This is intended to be used for packages which contain
> >   * more than one PHY, for example a quad PHY transceiver.
> >   *
> > - * The addr parameter serves as a cookie which has to have the same value
> > - * for all members of one group and as a PHY address to access generic
> > - * registers of a PHY package. Usually, one of the PHY addresses of the
> > - * different PHYs in the package provides access to these global registers.
> > + * The addr parameter serves as cookie which has to have the same values
> 
> addr has been renamed base_addr.
> 
> > + * for all members of one group and as the base PHY address of the PHY package
> > + * for offset calculation to access generic registers of a PHY package.
> > + * Usually, one of the PHY addresses of the different PHYs in the package
> > + * provides access to these global registers.
> >   * The address which is given here, will be used in the phy_package_read()
> > - * and phy_package_write() convenience functions. If your PHY doesn't have
> > - * global registers you can just pick any of the PHY addresses.
> > + * and phy_package_write() convenience functions as base and added to the
> > + * passed offset in those functions. If your PHY doesn't have global registers
> > + * you can just pick any of the PHY addresses.
> 
> 
> I would not add this last sentence. We want a clearly defined meaning
> of base_addr. Its the lowest address in the package. It does not
> matter if its not used, it should still be the lowest address in the
> package.
> 
> > + * In some special PHY package, multiple PHY are used for global init of
> 
> I don't see why they are special.
> 
> > -static inline int phy_package_read(struct phy_device *phydev, u32 regnum)
> > +static inline int phy_package_read(struct phy_device *phydev,
> > +				   unsigned int addr_offset, u32 regnum)
> >  {
> >  	struct phy_package_shared *shared = phydev->shared;
> > +	int addr;
> >  
> > -	if (!shared)
> > +	if (!shared || shared->base_addr + addr_offset > PHY_MAX_ADDR)
> >  		return -EIO;
> >  
> > -	return mdiobus_read(phydev->mdio.bus, shared->addr, regnum);
> > +	addr = shared->base_addr + addr_offset;
> > +	return mdiobus_read(phydev->mdio.bus, addr, regnum);
> 
> This might be a little bit more readable:
> 
> static inline int phy_package_read(struct phy_device *phydev,
> 				   unsigned int addr_offset, u32 regnum)
> {
> 	struct phy_package_shared *shared = phydev->shared;
> 	int addr = shared->base_addr + addr_offset;

Isn't this problematic if shared is NULL?

I can add 2 if condition and set addr in between only after shared not
NULL check is done?

> 
> 	if (!shared)
> 	if (!shared || addr > PHY_MAX_ADDR)
> 		return -EIO;
> 
> 	return mdiobus_read(phydev->mdio.bus, addr, regnum);
> }
> 
>

-- 
	Ansuel

  reply	other threads:[~2023-11-26 18:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-26  0:37 [net-next PATCH 1/3] net: phy: extend PHY package API to support multiple global address Christian Marangi
2023-11-26  0:37 ` [net-next PATCH 2/3] net: phy: move mmd_phy_indirect to generic header Christian Marangi
2023-11-26  0:37 ` [net-next PATCH 3/3] net: phy: add support for PHY package MMD read/write Christian Marangi
2023-11-26  0:52   ` Florian Fainelli
2023-11-26  0:54     ` Christian Marangi
2023-11-26  1:00       ` Florian Fainelli
2023-11-26 18:14   ` Andrew Lunn
2023-11-26 18:24     ` Christian Marangi
2023-11-26 18:04 ` [net-next PATCH 1/3] net: phy: extend PHY package API to support multiple global address Andrew Lunn
2023-11-26 18:07   ` Christian Marangi [this message]
2023-11-26 18:19     ` Andrew Lunn
2023-11-26 18:23       ` Christian Marangi
2023-11-26 19:39         ` Andrew Lunn

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=65638967.5d0a0220.28475.43b3@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=david.epping@missinglinkelectronics.com \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=harini.katakam@amd.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    /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.