* [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g
@ 2025-06-14 20:29 Heiner Kallweit
2025-06-14 20:30 ` [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device Heiner Kallweit
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Heiner Kallweit @ 2025-06-14 20:29 UTC (permalink / raw)
To: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, Russell King - ARM Linux
Cc: netdev@vger.kernel.org
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(-)
--
2.49.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device
2025-06-14 20:29 [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g Heiner Kallweit
@ 2025-06-14 20:30 ` Heiner Kallweit
2025-06-16 9:52 ` Russell King (Oracle)
2025-06-14 20:31 ` [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy Heiner Kallweit
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Heiner Kallweit @ 2025-06-14 20:30 UTC (permalink / raw)
To: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, Russell King - ARM Linux
Cc: netdev@vger.kernel.org
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_device.c | 13 +++++++------
include/linux/phy.h | 2 ++
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 73f9cb2e2..bbd8e3710 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index e194dad16..5b02b4319 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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 */
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy
2025-06-14 20:29 [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g Heiner Kallweit
2025-06-14 20:30 ` [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device Heiner Kallweit
@ 2025-06-14 20:31 ` Heiner Kallweit
2025-06-16 9:53 ` Russell King (Oracle)
2025-06-14 20:32 ` [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g Heiner Kallweit
2025-06-17 1:40 ` [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g patchwork-bot+netdevbpf
3 siblings, 1 reply; 8+ messages in thread
From: Heiner Kallweit @ 2025-06-14 20:31 UTC (permalink / raw)
To: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, Russell King - ARM Linux
Cc: netdev@vger.kernel.org
Use 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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
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(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bbd8e3710..c132ae977 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 5b02b4319..43852e711 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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 */
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g
2025-06-14 20:29 [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g Heiner Kallweit
2025-06-14 20:30 ` [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device Heiner Kallweit
2025-06-14 20:31 ` [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy Heiner Kallweit
@ 2025-06-14 20:32 ` Heiner Kallweit
2025-06-16 9:54 ` Russell King (Oracle)
2025-06-17 1:40 ` [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g patchwork-bot+netdevbpf
3 siblings, 1 reply; 8+ messages in thread
From: Heiner Kallweit @ 2025-06-14 20:32 UTC (permalink / raw)
To: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, Russell King - ARM Linux
Cc: netdev@vger.kernel.org
Remove now unused function phy_driver_is_genphy_10g().
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_device.c | 23 -----------------------
include/linux/phy.h | 2 --
2 files changed, 25 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c132ae977..e2b5d9016 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 43852e711..2347e5ecc 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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 */
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device
2025-06-14 20:30 ` [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device Heiner Kallweit
@ 2025-06-16 9:52 ` Russell King (Oracle)
0 siblings, 0 replies; 8+ messages in thread
From: Russell King (Oracle) @ 2025-06-16 9:52 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, netdev@vger.kernel.org
On Sat, Jun 14, 2025 at 10:30:43PM +0200, Heiner Kallweit wrote:
> 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.
>
> 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] 8+ messages in thread
* Re: [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy
2025-06-14 20:31 ` [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy Heiner Kallweit
@ 2025-06-16 9:53 ` Russell King (Oracle)
0 siblings, 0 replies; 8+ messages in thread
From: Russell King (Oracle) @ 2025-06-16 9:53 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, netdev@vger.kernel.org
On Sat, Jun 14, 2025 at 10:31:57PM +0200, Heiner Kallweit wrote:
> Use 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.
>
> 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] 8+ messages in thread
* Re: [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g
2025-06-14 20:32 ` [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g Heiner Kallweit
@ 2025-06-16 9:54 ` Russell King (Oracle)
0 siblings, 0 replies; 8+ messages in thread
From: Russell King (Oracle) @ 2025-06-16 9:54 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Andrew Lunn, Paolo Abeni, Jakub Kicinski, David Miller,
Eric Dumazet, Andrew Lunn, netdev@vger.kernel.org
On Sat, Jun 14, 2025 at 10:32:47PM +0200, Heiner Kallweit wrote:
> Remove now unused function phy_driver_is_genphy_10g().
>
> 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] 8+ messages in thread
* Re: [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g
2025-06-14 20:29 [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g Heiner Kallweit
` (2 preceding siblings ...)
2025-06-14 20:32 ` [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g Heiner Kallweit
@ 2025-06-17 1:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-17 1:40 UTC (permalink / raw)
To: Heiner Kallweit
Cc: andrew+netdev, pabeni, kuba, davem, edumazet, andrew, linux,
netdev
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 14 Jun 2025 22:29:38 +0200 you wrote:
> 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
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-17 1:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-14 20:29 [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g Heiner Kallweit
2025-06-14 20:30 ` [PATCH net-next v2 1/3] net: phy: add flag is_genphy_driven to struct phy_device Heiner Kallweit
2025-06-16 9:52 ` Russell King (Oracle)
2025-06-14 20:31 ` [PATCH net-next v2 2/3] net: phy: improve phy_driver_is_genphy Heiner Kallweit
2025-06-16 9:53 ` Russell King (Oracle)
2025-06-14 20:32 ` [PATCH net-next v2 3/3] net: phy: remove phy_driver_is_genphy_10g Heiner Kallweit
2025-06-16 9:54 ` Russell King (Oracle)
2025-06-17 1:40 ` [PATCH net-next v2 0/3] net: phy: remove phy_driver_is_genphy and phy_driver_is_genphy_10g 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).