Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: stmmac: mdio: use netdev_priv() directly

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>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
bafdd920 5e3aae2d

+10 -28
+10 -28
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
··· 131 131 static int stmmac_xgmac2_mdio_read_c22(struct mii_bus *bus, int phyaddr, 132 132 int phyreg) 133 133 { 134 - struct net_device *ndev = bus->priv; 135 - struct stmmac_priv *priv; 134 + struct stmmac_priv *priv = netdev_priv(bus->priv); 136 135 u32 addr; 137 - 138 - priv = netdev_priv(ndev); 139 136 140 137 /* Until ver 2.20 XGMAC does not support C22 addr >= 4 */ 141 138 if (priv->synopsys_id < DWXGMAC_CORE_2_20 && ··· 147 150 static int stmmac_xgmac2_mdio_read_c45(struct mii_bus *bus, int phyaddr, 148 151 int devad, int phyreg) 149 152 { 150 - struct net_device *ndev = bus->priv; 151 - struct stmmac_priv *priv; 153 + struct stmmac_priv *priv = netdev_priv(bus->priv); 152 154 u32 addr; 153 - 154 - priv = netdev_priv(ndev); 155 155 156 156 stmmac_xgmac2_c45_format(priv, phyaddr, devad, phyreg, &addr); 157 157 ··· 203 209 static int stmmac_xgmac2_mdio_write_c22(struct mii_bus *bus, int phyaddr, 204 210 int phyreg, u16 phydata) 205 211 { 206 - struct net_device *ndev = bus->priv; 207 - struct stmmac_priv *priv; 212 + struct stmmac_priv *priv = netdev_priv(bus->priv); 208 213 u32 addr; 209 - 210 - priv = netdev_priv(ndev); 211 214 212 215 /* Until ver 2.20 XGMAC does not support C22 addr >= 4 */ 213 216 if (priv->synopsys_id < DWXGMAC_CORE_2_20 && ··· 220 229 static int stmmac_xgmac2_mdio_write_c45(struct mii_bus *bus, int phyaddr, 221 230 int devad, int phyreg, u16 phydata) 222 231 { 223 - struct net_device *ndev = bus->priv; 224 - struct stmmac_priv *priv; 232 + struct stmmac_priv *priv = netdev_priv(bus->priv); 225 233 u32 addr; 226 - 227 - priv = netdev_priv(ndev); 228 234 229 235 stmmac_xgmac2_c45_format(priv, phyaddr, devad, phyreg, &addr); 230 236 ··· 262 274 */ 263 275 static int stmmac_mdio_read_c22(struct mii_bus *bus, int phyaddr, int phyreg) 264 276 { 265 - struct net_device *ndev = bus->priv; 266 - struct stmmac_priv *priv = netdev_priv(ndev); 277 + struct stmmac_priv *priv = netdev_priv(bus->priv); 267 278 u32 value = MII_BUSY; 268 279 int data = 0; 269 280 ··· 299 312 static int stmmac_mdio_read_c45(struct mii_bus *bus, int phyaddr, int devad, 300 313 int phyreg) 301 314 { 302 - struct net_device *ndev = bus->priv; 303 - struct stmmac_priv *priv = netdev_priv(ndev); 315 + struct stmmac_priv *priv = netdev_priv(bus->priv); 304 316 u32 value = MII_BUSY; 305 317 int data = 0; 306 318 ··· 359 373 static int stmmac_mdio_write_c22(struct mii_bus *bus, int phyaddr, int phyreg, 360 374 u16 phydata) 361 375 { 362 - struct net_device *ndev = bus->priv; 363 - struct stmmac_priv *priv = netdev_priv(ndev); 376 + struct stmmac_priv *priv = netdev_priv(bus->priv); 364 377 int ret, data = phydata; 365 378 u32 value = MII_BUSY; 366 379 ··· 397 412 static int stmmac_mdio_write_c45(struct mii_bus *bus, int phyaddr, 398 413 int devad, int phyreg, u16 phydata) 399 414 { 400 - struct net_device *ndev = bus->priv; 401 - struct stmmac_priv *priv = netdev_priv(ndev); 415 + struct stmmac_priv *priv = netdev_priv(bus->priv); 402 416 int ret, data = phydata; 403 417 u32 value = MII_BUSY; 404 418 ··· 436 452 int stmmac_mdio_reset(struct mii_bus *bus) 437 453 { 438 454 #if IS_ENABLED(CONFIG_STMMAC_PLATFORM) 439 - struct net_device *ndev = bus->priv; 440 - struct stmmac_priv *priv = netdev_priv(ndev); 455 + struct stmmac_priv *priv = netdev_priv(bus->priv); 441 456 unsigned int mii_address = priv->hw->mii.addr; 442 457 443 458 #ifdef CONFIG_OF ··· 480 497 481 498 int stmmac_pcs_setup(struct net_device *ndev) 482 499 { 500 + struct stmmac_priv *priv = netdev_priv(ndev); 483 501 struct fwnode_handle *devnode, *pcsnode; 484 502 struct dw_xpcs *xpcs = NULL; 485 - struct stmmac_priv *priv; 486 503 int addr, ret; 487 504 488 - priv = netdev_priv(ndev); 489 505 devnode = priv->plat->port_node; 490 506 491 507 if (priv->plat->pcs_init) {