]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: mdio: use netdev_priv() directly
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 27 Aug 2025 08:41:48 +0000 (09:41 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 28 Aug 2025 23:44:03 +0000 (16:44 -0700)
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>
Link: https://patch.msgid.link/E1urBj2-000000002as-0pod@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

index 836f2848dfeb8cf23a04e02f7401fb8c22c3ab44..86021e6b67b2e2465cd32071480eeb0b300e6168 100644 (file)
@@ -131,12 +131,9 @@ err_disable_clks:
 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 @@ err_disable_clks:
 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) {