* [PATCH net-next] net: stmmac: mdio: use netdev_priv() directly
@ 2025-08-27 8:41 Russell King (Oracle)
2025-08-27 11:23 ` Subbaraya Sundeep
2025-08-29 0:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-08-27 8:41 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
netdev, Paolo Abeni
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>
---
.../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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: stmmac: mdio: use netdev_priv() directly
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
2025-08-29 0:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Subbaraya Sundeep @ 2025-08-27 11:23 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, linux-arm-kernel,
linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: stmmac: mdio: use netdev_priv() directly
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
@ 2025-08-29 0:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-29 0:00 UTC (permalink / raw)
To: Russell King
Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, davem,
edumazet, kuba, linux-arm-kernel, linux-stm32, mcoquelin.stm32,
netdev, pabeni
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 27 Aug 2025 09:41:48 +0100 you 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);
>
> [...]
Here is the summary with links:
- [net-next] net: stmmac: mdio: use netdev_priv() directly
https://git.kernel.org/netdev/net-next/c/bafdd920a060
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-29 0:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-08-29 0:00 ` patchwork-bot+netdevbpf
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).