net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g
Subsystems (3)
Heiner Kallweit
maintainerv2 cover net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g
Replace phy_driver_is_genphy() and phy_driver_is_genphy_10g() with a new flag in struct phy_device.
v2:
- fix a kdoc issue in patch 2
Heiner Kallweit (3):
net: phy: add flag is_genphy_driven to struct phy_device
net: phy: improve phy_driver_is_genphy
net: phy: remove phy_driver_is_genphy_10g
drivers/net/phy/phy_device.c | 43 ++++++------------------------------ include/linux/phy.h | 16 +++++++++++--- 2 files changed, 20 insertions(+), 39 deletions(-)
Signature · 1 line
2.49.0
Heiner Kallweit
maintainerPATCH v2 1/3 net: phy: add flag is_genphy_driven to struct phy_device
In order to get rid of phy_driver_is_genphy() and phy_driver_is_genphy_10g(), as first step add and use a flag phydev->is_genphy_driven.
--- drivers/net/phy/phy_device.c | 13 +++++++------ include/linux/phy.h | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/phy/phy_device.c +7 -6
@@ -1515,7 +1515,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,struct mii_bus *bus = phydev->mdio.bus;struct device *d = &phydev->mdio.dev;struct module *ndev_owner =NULL ; -bool using_genphy = false;int err;/* For Ethernet device drivers that register their own MDIO bus, we
@@ -1541,7 +1540,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,else d->driver = &genphy_driver.mdiodrv.driver; - using_genphy = true; + phydev->is_genphy_driven =1 ; }if (!try_module_get (d->driver->owner)) {
@@ -1550,7 +1549,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, goto error_put_device; } -if (using_genphy) { +if (phydev->is_genphy_driven) { err = d->driver->probe (d);if (err >=0 ) err =device_bind_driver (d);
@@ -1620,7 +1619,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,* the generic PHY driver we can't figure it out, thus set the old * legacy PORT_MII value. */ -if (using_genphy) +if (phydev->is_genphy_driven) phydev->port =PORT_MII ;/* Initial carrier state is off as the phy is about to be
@@ -1659,6 +1658,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, error_module_put:module_put (d->driver->owner); + phydev->is_genphy_driven =0 ; d->driver =NULL ; error_put_device:put_device (d);
@@ -1792,9 +1792,10 @@ void phy_detach(struct phy_device *phydev)* from the generic driver so that there's a chance a * real driver could be loaded */ -if (phy_driver_is_genphy (phydev) || -phy_driver_is_genphy_10g (phydev)) +if (phydev->is_genphy_driven) {device_release_driver (&phydev->mdio.dev); + phydev->is_genphy_driven =0 ; + }/* Assert the reset signal */ phy_device_reset (phydev,1 );
include/linux/phy.h +2 -0
@@ -526,6 +526,7 @@ struct macsec_ops;* @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY * @wol_enabled: Set to true if the PHY or the attached MAC have Wake-on-LAN * enabled. +* @is_genphy_driven: PHY is driven by one of the generic PHY drivers * @state: State of the PHY for management purposes * @dev_flags: Device-specific flags used by the PHY driver. *
@@ -629,6 +630,7 @@ struct phy_device { unsigned is_on_sfp_module:1; unsigned mac_managed_pm:1; unsigned wol_enabled:1; + unsigned is_genphy_driven:1; unsigned autoneg:1;/* The most recently read link state */
Signature · 1 line
2.49.0
Re: [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device
Quoted 5 lines · Heiner Kallweit
In order to get rid of
phy_driver_is_genphy()andphy_driver_is_genphy_10g(), as first step add and use a flagphydev->is_genphy_driven.Signed-off-by Heiner Kallweit <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Heiner Kallweit
maintainerPATCH v2 2/3 net: phy: improve phy_driver_is_genphy
In reply to Heiner KallweitUse new flag phydev->is_genphy_driven to simplify this function. Note that this includes a minor functional change:
Now this function returns true if ANY of the genphy drivers is bound to the PHY device.
We have only one user in DSA driver mt7530, and there the functional change doesn't matter.
---
v2:
- add return value description to kdoc
--- drivers/net/phy/phy_device.c | 7 ------- include/linux/phy.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/phy/phy_device.c +0 -7
@@ -1722,13 +1722,6 @@ static bool phy_driver_is_genphy_kind(struct phy_device *phydev,return ret; } -bool phy_driver_is_genphy (struct phy_device *phydev) -{ -return phy_driver_is_genphy_kind (phydev, - &genphy_driver.mdiodrv.driver); -} -EXPORT_SYMBOL_GPL (phy_driver_is_genphy); -bool phy_driver_is_genphy_10g (struct phy_device *phydev) { return phy_driver_is_genphy_kind(phydev,
include/linux/phy.h +11 -1
@@ -1293,6 +1293,17 @@ static inline bool phy_is_started(struct phy_device *phydev)return phydev->state >=PHY_UP ; } +/** +* phy_driver_is_genphy - Convenience function to check whether PHY is driven +* by one of the generic PHY drivers +* @phydev: The phy_device struct +* Return: true if PHY is driven by one of the genphy drivers +*/ +static inline bool phy_driver_is_genphy (struct phy_device *phydev) +{ +return phydev->is_genphy_driven; +} +/** * phy_disable_eee_mode - Don't advertise an EEE mode. * @phydev: The phy_device struct
@@ -2098,7 +2109,6 @@ module_exit(phy_module_exit)#define module_phy_driver (__phy_drivers) \ phy_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers)) -bool phy_driver_is_genphy (struct phy_device *phydev);bool phy_driver_is_genphy_10g (struct phy_device *phydev);#endif /* __PHY_H */
Signature · 1 line
2.49.0
Re: [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy
Quoted 9 lines · Heiner Kallweit
Use new flag
phydev->is_genphy_drivento simplify this function. Note that this includes a minor functional change:
Now this function returns true if ANY of the genphy drivers is bound to the PHY device.We have only one user in DSA driver mt7530, and there the functional change doesn't matter.
Signed-off-by Heiner Kallweit <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Heiner Kallweit
maintainerPATCH v2 3/3 net: phy: remove phy_driver_is_genphy_10g
In reply to Heiner KallweitRemove now unused function phy_driver_is_genphy_10g().
--- drivers/net/phy/phy_device.c | 23 ----------------------- include/linux/phy.h | 2 -- 2 files changed, 25 deletions(-)
drivers/net/phy/phy_device.c +0 -23
@@ -1706,29 +1706,6 @@ struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, }EXPORT_SYMBOL (phy_attach); -static bool phy_driver_is_genphy_kind (struct phy_device *phydev, -struct device_driver *driver) -{ -struct device *d = &phydev->mdio.dev; -bool ret = false; - -if (!phydev->drv) -return ret; - -get_device (d); - ret = d->driver == driver; -put_device (d); - -return ret; -} - -bool phy_driver_is_genphy_10g (struct phy_device *phydev) -{ -return phy_driver_is_genphy_kind (phydev, - &genphy_c45_driver.mdiodrv.driver); -} -EXPORT_SYMBOL_GPL (phy_driver_is_genphy_10g); -/** * phy_detach - detach a PHY device from its network device * @phydev: target phy_device struct
include/linux/phy.h +0 -2
@@ -2109,6 +2109,4 @@ module_exit(phy_module_exit)#define module_phy_driver (__phy_drivers) \ phy_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers)) -bool phy_driver_is_genphy_10g (struct phy_device *phydev); -#endif /* __PHY_H */
Signature · 1 line
2.49.0
Re: [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g
Quoted 3 lines · Heiner Kallweit
Remove now unused function
phy_driver_is_genphy_10g().Signed-off-by Heiner Kallweit <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Sat, 14 Jun 2025 22:29:38 +0200 you wrote:
Replace
phy_driver_is_genphy()andphy_driver_is_genphy_10g()with a new flag in structphy_device.v2:
- fix a kdoc issue in patch 2
Quoted 6 lines
Heiner Kallweit (3):
net: phy: add flagis_genphy_drivento structphy_device
net: phy: improvephy_driver_is_genphy
net: phy: removephy_driver_is_genphy_10g[...]
Here is the summary with links:
- [net-next,v2,1/3] net: phy: add flag is_genphy_driven to struct phy_device
https://git.kernel.org/netdev/net-next/c/2796ff1e3dca - [net-next,v2,2/3] net: phy: improve phy_driver_is_genphy https://git.kernel.org/netdev/net-next/c/59e74c92e67e - [net-next,v2,3/3] net: phy: remove phy_driver_is_genphy_10g https://git.kernel.org/netdev/net-next/c/42ed7f7e94da
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html