net: phy: fixed_phy: add helper fixed_phy_register_100fd
Subsystems (4)
Heiner Kallweit
maintainercover net: phy: fixed_phy: add helper fixed_phy_register_100fd
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct fixed_phy_status. First user is the dsa loop driver. A follow-up series will remove the usage of fixed_phy_add() from bcm47xx and coldfire/m5272, then this helper will be used too.
Heiner Kallweit (2):
net: phy: fixed_phy: add helper fixed_phy_register_100fd
net: dsa: loop: use new helper fixed_phy_register_100fd
drivers/net/dsa/dsa_loop.c | 7 +------ drivers/net/phy/fixed_phy.c | 12 ++++++++++++ include/linux/phy_fixed.h | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-)
Signature · 1 line
2.51.1.dirty
Heiner Kallweit
maintainerPATCH 1/2 net: phy: fixed_phy: add helper fixed_phy_register_100fd
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct fixed_phy_status.
--- drivers/net/phy/fixed_phy.c | 12 ++++++++++++ include/linux/phy_fixed.h | 6 ++++++ 2 files changed, 18 insertions(+)
drivers/net/phy/fixed_phy.c +12 -0
@@ -227,6 +227,18 @@ struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, }EXPORT_SYMBOL_GPL (fixed_phy_register); +struct phy_device *fixed_phy_register_100fd (void ) +{ +static const struct fixed_phy_status status = { + .link =1 , + .speed =SPEED_100 , + .duplex =DUPLEX_FULL , + }; + +return fixed_phy_register (&status,NULL ); +} +EXPORT_SYMBOL_GPL (fixed_phy_register_100fd); +void fixed_phy_unregister (struct phy_device *phy) {phy_device_remove (phy);
include/linux/phy_fixed.h +6 -0
@@ -20,6 +20,7 @@ extern int fixed_phy_change_carrier(struct net_device *dev, bool new_carrier);void fixed_phy_add (const struct fixed_phy_status *status);struct phy_device *fixed_phy_register (const struct fixed_phy_status *status,struct device_node *np); +struct phy_device *fixed_phy_register_100fd (void );extern void fixed_phy_unregister (struct phy_device *phydev); extern int fixed_phy_set_link_update(struct phy_device *phydev,
@@ -34,6 +35,11 @@ fixed_phy_register(const struct fixed_phy_status *status,return ERR_PTR (-ENODEV ); } +static inline struct phy_device *fixed_phy_register_100fd (void ) +{ +return ERR_PTR (-ENODEV ); +} +static inline void fixed_phy_unregister (struct phy_device *phydev) { }
Signature · 1 line
2.51.1.dirty
Quoted 46 lines · Heiner Kallweit
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct
fixed_phy_status.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/phy/fixed_phy.c | 12 ++++++++++++ include/linux/phy_fixed.h | 6 ++++++ 2 files changed, 18 insertions(+)drivers/net/phy/fixed_phy.c +12
-0@@ -227,6 +227,18 @@ struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, }EXPORT_SYMBOL_GPL (fixed_phy_register); +struct phy_device *fixed_phy_register_100fd (void ) +{ +static const struct fixed_phy_status status = { + .link =1 , + .speed =SPEED_100 , + .duplex =DUPLEX_FULL , + }; + +return fixed_phy_register (&status,NULL ); +} +EXPORT_SYMBOL_GPL (fixed_phy_register_100fd); +void fixed_phy_unregister (struct phy_device *phy) {phy_device_remove (phy);include/linux/phy_fixed.h +1
-0@@ -20,6 +20,7 @@ extern int fixed_phy_change_carrier(struct net_device *dev, bool new_carrier);void fixed_phy_add (const struct fixed_phy_status *status);struct phy_device *fixed_phy_register (const struct fixed_phy_status *status,struct device_node *np); +struct phy_device *fixed_phy_register_100fd (void );extern void fixed_phy_unregister (struct phy_device *phydev); extern int fixed_phy_set_link_update(struct phy_device *phydev,@@ -34,6 +35,11 @@ fixed_phy_register(const struct fixed_phy_status *status,return ERR_PTR (-ENODEV );
include/linux/phy_fixed.h fixed_phy_register(const struct fixed_phy_status *status, · line 45
Quoted 10 lines
include/linux/phy_fixed.h +5
-0} +static inline struct phy_device *fixed_phy_register_100fd (void ) +{ +return ERR_PTR (-ENODEV ); +} +static inline void fixed_phy_unregister (struct phy_device *phydev) { }
Quoted 18 lines · Heiner Kallweit
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct
fixed_phy_status.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/phy/fixed_phy.c | 12 ++++++++++++ include/linux/phy_fixed.h | 6 ++++++ 2 files changed, 18 insertions(+)drivers/net/phy/fixed_phy.c +1
-0@@ -227,6 +227,18 @@ struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, }EXPORT_SYMBOL_GPL (fixed_phy_register); +struct phy_device *fixed_phy_register_100fd (void )
drivers/net/phy/fixed_phy.c struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, · line 240
Quoted 10 lines
drivers/net/phy/fixed_phy.c +10
-0+{ +static const struct fixed_phy_status status = { + .link =1 , + .speed =SPEED_100 , + .duplex =DUPLEX_FULL , + }; + +return fixed_phy_register (&status,NULL ); +} +EXPORT_SYMBOL_GPL (fixed_phy_register_100fd);
Would not you want this to be a static inline helper directly?
Signature · 1 line
Florian
Heiner Kallweit
maintainerQuoted 22 lines · Florian Fainelli
Quoted 21 lines · Heiner Kallweit
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct
fixed_phy_status.Signed-off-by Heiner Kallweit <[email protected]>---
drivers/net/phy/fixed_phy.c| 12 ++++++++++++
include/linux/phy_fixed.h | 6 ++++++2 files changed, 18 insertions(+)drivers/net/phy/fixed_phy.c +4
-0@@ -227,6 +227,18 @@ struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, } EXPORT_SYMBOL_GPL(fixed_phy_register); +struct phy_device *fixed_phy_register_100fd(void) +{ + static const struct fixed_phy_status status = { + .link = 1, + .speed = SPEED_100,
Quoted 8 lines
drivers/net/phy/fixed_phy.c struct phy_device *fixed_phy_register(const struct fixed_phy_status *status, · line 240
Quoted 6 lines
drivers/net/phy/fixed_phy.c +6
-0+ .duplex = DUPLEX_FULL, + }; + + return fixed_phy_register(&status, NULL); +} +EXPORT_SYMBOL_GPL (fixed_phy_register_100fd);Would not you want this to be a static inline helper directly?
Wouldn't then again each user allocate its own struct fixed_phy_status? As-is we allocate it only once.
Heiner Kallweit
maintainerPATCH 2/2 net: dsa: loop: use new helper fixed_phy_register_100fd
In reply to Heiner KallweitUse new helper fixed_phy_register_100fd() to simplify the code.
--- drivers/net/dsa/dsa_loop.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/net/dsa/dsa_loop.c +1 -6
@@ -441,11 +441,6 @@ static int __init dsa_loop_create_switch_mdiodev(void)static int __init dsa_loop_init (void ) { -struct fixed_phy_status status = { - .link =1 , - .speed =SPEED_100 , - .duplex =DUPLEX_FULL , - };unsigned int i;int ret;
@@ -454,7 +449,7 @@ static int __init dsa_loop_init(void)return ret;for (i =0 ; i <NUM_FIXED_PHYS ; i++) - phydevs[i] =fixed_phy_register (&status,NULL ); + phydevs[i] =fixed_phy_register_100fd (); ret =mdio_driver_register (&dsa_loop_drv);if (ret) {
Signature · 1 line
2.51.1.dirty
Re: [PATCH net-next 2/2] net: dsa: loop: use new helper fixed_phy_register_100fd
Quoted 24 lines · Heiner Kallweit
Use new helper
fixed_phy_register_100fd()to simplify the code.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/dsa/dsa_loop.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/net/dsa/dsa_loop.c +0
-5@@ -441,11 +441,6 @@ static int __init dsa_loop_create_switch_mdiodev(void)static int __init dsa_loop_init (void ) { -struct fixed_phy_status status = { - .link =1 , - .speed =SPEED_100 , - .duplex =DUPLEX_FULL , - };unsigned int i;int ret;
drivers/net/dsa/dsa_loop.c static int __init dsa_loop_init(void) · line 455
Quoted 8 lines
drivers/net/dsa/dsa_loop.c +1
-1@@ -454,7 +449,7 @@ static int __init dsa_loop_init(void)return ret;for (i =0 ; i <NUM_FIXED_PHYS ; i++) - phydevs[i] =fixed_phy_register (&status,NULL ); + phydevs[i] =fixed_phy_register_100fd (); ret =mdio_driver_register (&dsa_loop_drv);if (ret) {
Jakub Kicinski
maintainerQuoted 5 lines · On Fri, 17 Oct 2025 22:11:44 +0200 Heiner Kallweit wrote:
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct
fixed_phy_status. First user is the dsa loop driver. A follow-up series will remove the usage offixed_phy_add()from bcm47xx and coldfire/m5272, then this helper will be used too.
Not knowing the area too well it looks like struct fixed_phy_status is an argument struct to make it easier to add / pass thru extra attrs without having to modify all the callers. This series goes in the opposite direction trying to make the callers not have to declare the argument struct.
When reading the code it may also be easier to graps the code if the definition is local vs having to look at fixed_phy_register_100fd() Granted the function name kinda makes it obvious what it does.
Lastly: 19 insertions(+), 6 deletions(-)
So the improvement here is not immediately obvious to me. Maybe it'd be easier to appreciate this series if it was in one piece with what you mentioned as a follow up?
Heiner Kallweit
maintainerQuoted 17 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 17 Oct 2025 22:11:44 +0200 Heiner Kallweit wrote:
In few places a 100FD fixed PHY is used. Create a helper so that users don't have to define the struct
fixed_phy_status. First user is the dsa loop driver. A follow-up series will remove the usage offixed_phy_add()from bcm47xx and coldfire/m5272, then this helper will be used too.Not knowing the area too well it looks like struct
fixed_phy_statusis an argument struct to make it easier to add / pass thru extra attrs without having to modify all the callers. This series goes in the opposite direction trying to make the callers not have to declare the argument struct.When reading the code it may also be easier to graps the code if the definition is local vs having to look at
fixed_phy_register_100fd()Granted the function name kinda makes it obvious what it does.
Quoted 5 lines
Lastly: 19 insertions(+), 6 deletions(-)
So the improvement here is not immediately obvious to me. Maybe it'd be easier to appreciate this series if it was in one piece with what you mentioned as a follow up?
Makes sense, I'll prepare and submit the full series.