[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aK7qzc_uVt2A53NH@opensource>
Date: Wed, 27 Aug 2025 11:23:57 +0000
From: Subbaraya Sundeep <sbhatta@...vell.com>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
CC: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Andrew Lunn
<andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric
Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-stm32@...md-mailman.stormreply.com>,
Maxime Coquelin
<mcoquelin.stm32@...il.com>, <netdev@...r.kernel.org>,
Paolo Abeni
<pabeni@...hat.com>
Subject: Re: [PATCH net-next] net: stmmac: mdio: use netdev_priv() directly
On 2025-08-27 at 08:41:48, Russell King (Oracle) (rmk+kernel@...linux.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@...linux.org.uk>
Reviewed-by: Subbaraya Sundeep <sbhatta@...vell.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
>
Powered by blists - more mailing lists