netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Subbaraya Sundeep <sbhatta@marvell.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	<netdev@vger.kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next] net: stmmac: mdio: use netdev_priv() directly
Date: Wed, 27 Aug 2025 11:23:57 +0000	[thread overview]
Message-ID: <aK7qzc_uVt2A53NH@opensource> (raw)
In-Reply-To: <E1urBj2-000000002as-0pod@rmk-PC.armlinux.org.uk>

On 2025-08-27 at 08:41:48, Russell King (Oracle) (rmk+kernel@armlinux.org.uk) wrote:
> netdev_priv() is an inline function, taking a struct net_device
> pointer. When passing in the MII bus->priv, which is a void pointer,
> there is no need to go via a local ndev variable to type it first.
> 
> Thus, instead of:
> 
> 	struct net_device *ndev = bus->priv;
> 	struct stmmac_priv *priv;
> ...
> 	priv = netdev_priv(ndev);
> 
> we can simply do:
> 
> 	struct stmmac_priv *priv = netdev_priv(bus->priv);
> 
> which simplifies the code.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Subbaraya Sundeep <sbhatta@marvell.com>

Thanks,
Sundeep

> ---
>  .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 38 +++++--------------
>  1 file changed, 10 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index 836f2848dfeb..86021e6b67b2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -131,12 +131,9 @@ static int stmmac_xgmac2_mdio_read(struct stmmac_priv *priv, u32 addr,
>  static int stmmac_xgmac2_mdio_read_c22(struct mii_bus *bus, int phyaddr,
>  				       int phyreg)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv;
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	u32 addr;
>  
> -	priv = netdev_priv(ndev);
> -
>  	/* Until ver 2.20 XGMAC does not support C22 addr >= 4 */
>  	if (priv->synopsys_id < DWXGMAC_CORE_2_20 &&
>  	    phyaddr > MII_XGMAC_MAX_C22ADDR)
> @@ -150,12 +147,9 @@ static int stmmac_xgmac2_mdio_read_c22(struct mii_bus *bus, int phyaddr,
>  static int stmmac_xgmac2_mdio_read_c45(struct mii_bus *bus, int phyaddr,
>  				       int devad, int phyreg)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv;
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	u32 addr;
>  
> -	priv = netdev_priv(ndev);
> -
>  	stmmac_xgmac2_c45_format(priv, phyaddr, devad, phyreg, &addr);
>  
>  	return stmmac_xgmac2_mdio_read(priv, addr, MII_XGMAC_BUSY);
> @@ -209,12 +203,9 @@ static int stmmac_xgmac2_mdio_write(struct stmmac_priv *priv, u32 addr,
>  static int stmmac_xgmac2_mdio_write_c22(struct mii_bus *bus, int phyaddr,
>  					int phyreg, u16 phydata)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv;
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	u32 addr;
>  
> -	priv = netdev_priv(ndev);
> -
>  	/* Until ver 2.20 XGMAC does not support C22 addr >= 4 */
>  	if (priv->synopsys_id < DWXGMAC_CORE_2_20 &&
>  	    phyaddr > MII_XGMAC_MAX_C22ADDR)
> @@ -229,12 +220,9 @@ static int stmmac_xgmac2_mdio_write_c22(struct mii_bus *bus, int phyaddr,
>  static int stmmac_xgmac2_mdio_write_c45(struct mii_bus *bus, int phyaddr,
>  					int devad, int phyreg, u16 phydata)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv;
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	u32 addr;
>  
> -	priv = netdev_priv(ndev);
> -
>  	stmmac_xgmac2_c45_format(priv, phyaddr, devad, phyreg, &addr);
>  
>  	return stmmac_xgmac2_mdio_write(priv, addr, MII_XGMAC_BUSY,
> @@ -274,8 +262,7 @@ static int stmmac_mdio_read(struct stmmac_priv *priv, int data, u32 value)
>   */
>  static int stmmac_mdio_read_c22(struct mii_bus *bus, int phyaddr, int phyreg)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv = netdev_priv(ndev);
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	u32 value = MII_BUSY;
>  	int data = 0;
>  
> @@ -312,8 +299,7 @@ static int stmmac_mdio_read_c22(struct mii_bus *bus, int phyaddr, int phyreg)
>  static int stmmac_mdio_read_c45(struct mii_bus *bus, int phyaddr, int devad,
>  				int phyreg)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv = netdev_priv(ndev);
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	u32 value = MII_BUSY;
>  	int data = 0;
>  
> @@ -373,8 +359,7 @@ static int stmmac_mdio_write(struct stmmac_priv *priv, int data, u32 value)
>  static int stmmac_mdio_write_c22(struct mii_bus *bus, int phyaddr, int phyreg,
>  				 u16 phydata)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv = netdev_priv(ndev);
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	int ret, data = phydata;
>  	u32 value = MII_BUSY;
>  
> @@ -412,8 +397,7 @@ static int stmmac_mdio_write_c22(struct mii_bus *bus, int phyaddr, int phyreg,
>  static int stmmac_mdio_write_c45(struct mii_bus *bus, int phyaddr,
>  				 int devad, int phyreg, u16 phydata)
>  {
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv = netdev_priv(ndev);
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	int ret, data = phydata;
>  	u32 value = MII_BUSY;
>  
> @@ -452,8 +436,7 @@ static int stmmac_mdio_write_c45(struct mii_bus *bus, int phyaddr,
>  int stmmac_mdio_reset(struct mii_bus *bus)
>  {
>  #if IS_ENABLED(CONFIG_STMMAC_PLATFORM)
> -	struct net_device *ndev = bus->priv;
> -	struct stmmac_priv *priv = netdev_priv(ndev);
> +	struct stmmac_priv *priv = netdev_priv(bus->priv);
>  	unsigned int mii_address = priv->hw->mii.addr;
>  
>  #ifdef CONFIG_OF
> @@ -497,12 +480,11 @@ int stmmac_mdio_reset(struct mii_bus *bus)
>  
>  int stmmac_pcs_setup(struct net_device *ndev)
>  {
> +	struct stmmac_priv *priv = netdev_priv(ndev);
>  	struct fwnode_handle *devnode, *pcsnode;
>  	struct dw_xpcs *xpcs = NULL;
> -	struct stmmac_priv *priv;
>  	int addr, ret;
>  
> -	priv = netdev_priv(ndev);
>  	devnode = priv->plat->port_node;
>  
>  	if (priv->plat->pcs_init) {
> -- 
> 2.47.2
> 

  reply	other threads:[~2025-08-27 11:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27  8:41 [PATCH net-next] net: stmmac: mdio: use netdev_priv() directly Russell King (Oracle)
2025-08-27 11:23 ` Subbaraya Sundeep [this message]
2025-08-29  0:00 ` patchwork-bot+netdevbpf

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=aK7qzc_uVt2A53NH@opensource \
    --to=sbhatta@marvell.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).