net: phy: fixed_phy: let fixed_phy_unregister free the phy_device

[ Upstream commit a0f849c1cc6df0db9083b4c81c05a5456b1ed0fb ]

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>
Link: https://patch.msgid.link/ad8dda9a-10ed-4060-916b-3f13bdbb899d@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Heiner Kallweit
2025-08-23 23:25:05 +02:00
committed by Greg Kroah-Hartman
parent 4aa5acd88f
commit bb9b505f02
3 changed files with 4 additions and 7 deletions

View File

@@ -378,13 +378,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)

View File

@@ -440,6 +440,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);

View File

@@ -329,6 +329,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);