public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device
@ 2025-08-23 21:25 Heiner Kallweit
  2025-08-24  8:11 ` Russell King (Oracle)
  2025-08-27  0:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2025-08-23 21:25 UTC (permalink / raw)
  To: Vladimir Oltean, Andrew Lunn, Andrew Lunn,
	Russell King - ARM Linux, Jakub Kicinski, Paolo Abeni,
	David Miller, Eric Dumazet
  Cc: netdev@vger.kernel.org

fixed_phy_register() creates and registers the phy_device. To be
symmetric, we should not only unregister, but also free the phy_device
in fixed_phy_unregister(). This allows to simplify code in users.

Note wrt of_phy_deregister_fixed_link():
put_device(&phydev->mdio.dev) and phy_device_free(phydev) are identical.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/dsa/dsa_loop.c  | 9 +++------
 drivers/net/mdio/of_mdio.c  | 1 -
 drivers/net/phy/fixed_phy.c | 1 +
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index d8a35f25a..ad907287a 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -386,13 +386,10 @@ static struct mdio_driver dsa_loop_drv = {
 
 static void dsa_loop_phydevs_unregister(void)
 {
-	unsigned int i;
-
-	for (i = 0; i < NUM_FIXED_PHYS; i++)
-		if (!IS_ERR(phydevs[i])) {
+	for (int i = 0; i < NUM_FIXED_PHYS; i++) {
+		if (!IS_ERR(phydevs[i]))
 			fixed_phy_unregister(phydevs[i]);
-			phy_device_free(phydevs[i]);
-		}
+	}
 }
 
 static int __init dsa_loop_init(void)
diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 98f667b12..d8ca63ed8 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -473,6 +473,5 @@ void of_phy_deregister_fixed_link(struct device_node *np)
 	fixed_phy_unregister(phydev);
 
 	put_device(&phydev->mdio.dev);	/* of_phy_find_device() */
-	phy_device_free(phydev);	/* fixed_phy_register() */
 }
 EXPORT_SYMBOL(of_phy_deregister_fixed_link);
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 1af05afb0..99621239a 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -304,6 +304,7 @@ void fixed_phy_unregister(struct phy_device *phy)
 	phy_device_remove(phy);
 	of_node_put(phy->mdio.dev.of_node);
 	fixed_phy_del(phy->mdio.addr);
+	phy_device_free(phy);
 }
 EXPORT_SYMBOL_GPL(fixed_phy_unregister);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device
  2025-08-23 21:25 [PATCH net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device Heiner Kallweit
@ 2025-08-24  8:11 ` Russell King (Oracle)
  2025-08-27  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-08-24  8:11 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Vladimir Oltean, Andrew Lunn, Andrew Lunn, Jakub Kicinski,
	Paolo Abeni, David Miller, Eric Dumazet, netdev@vger.kernel.org

On Sat, Aug 23, 2025 at 11:25:05PM +0200, Heiner Kallweit wrote:
> fixed_phy_register() creates and registers the phy_device. To be
> symmetric, we should not only unregister, but also free the phy_device
> in fixed_phy_unregister(). This allows to simplify code in users.
> 
> Note wrt of_phy_deregister_fixed_link():
> put_device(&phydev->mdio.dev) and phy_device_free(phydev) are identical.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device
  2025-08-23 21:25 [PATCH net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device Heiner Kallweit
  2025-08-24  8:11 ` Russell King (Oracle)
@ 2025-08-27  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-27  0:40 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: olteanv, andrew, andrew+netdev, linux, kuba, pabeni, davem,
	edumazet, netdev

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 23 Aug 2025 23:25:05 +0200 you wrote:
> fixed_phy_register() creates and registers the phy_device. To be
> symmetric, we should not only unregister, but also free the phy_device
> in fixed_phy_unregister(). This allows to simplify code in users.
> 
> Note wrt of_phy_deregister_fixed_link():
> put_device(&phydev->mdio.dev) and phy_device_free(phydev) are identical.
> 
> [...]

Here is the summary with links:
  - [net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device
    https://git.kernel.org/netdev/net-next/c/a0f849c1cc6d

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-27  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-23 21:25 [PATCH net-next] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device Heiner Kallweit
2025-08-24  8:11 ` Russell King (Oracle)
2025-08-27  0:40 ` 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