Skip to contentSkip to conversation

net: phy: fixed_phy: simplifications and improvements

PATCH Applied Heiner Kallweit 5 participants 12 messages May 17, 2025 – May 21, 2025

Subsystems (13)
Networking Network drivers USB MIPS +9 more subsystems
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: fixed_phy: simplifications and improvements

This series includes two types of changes:
- All callers pass PHY_POLL, therefore remove irq argument
- constify the passed struct fixed_phy_status *status

Heiner Kallweit (3):
net: phy: fixed_phy: remove irq argument from fixed_phy_add
net: phy: fixed_phy: remove irq argument from fixed_phy_register
net: phy: fixed_phy: constify status argument where possible

 arch/m68k/coldfire/m5272.c                   |  2 +-
 arch/mips/bcm47xx/setup.c                    |  2 +-
 drivers/net/dsa/dsa_loop.c                   |  2 +-
 drivers/net/ethernet/broadcom/bgmac.c        |  2 +-
 drivers/net/ethernet/broadcom/genet/bcmmii.c |  2 +-
 drivers/net/ethernet/faraday/ftgmac100.c     |  2 +-
 drivers/net/mdio/of_mdio.c                   |  2 +-
 drivers/net/phy/fixed_phy.c                  | 12 +++++-------
 drivers/net/usb/lan78xx.c                    |  2 +-
 include/linux/phy_fixed.h                    | 18 ++++++++----------
 10 files changed, 21 insertions(+), 25 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 1/3 net: phy: fixed_phy: remove irq argument from fixed_phy_add

All callers pass PHY_POLL, therefore remove irq argument from fixed_phy_add().

---
 arch/m68k/coldfire/m5272.c  | 2 +-
 arch/mips/bcm47xx/setup.c   | 2 +-
 drivers/net/phy/fixed_phy.c | 5 ++---
 include/linux/phy_fixed.h   | 5 ++---
 4 files changed, 6 insertions(+), 8 deletions(-)
arch/m68k/coldfire/m5272.c +1 -1
index 734dab657..5b70dfdab 100644
@@ -119,7 +119,7 @@ static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
 static int __init init_BSP(void)
 {
 	m5272_uarts_init();
-	fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
+	fixed_phy_add(0, &nettel_fixed_phy_status);
 	clkdev_add_table(m5272_clk_lookup, ARRAY_SIZE(m5272_clk_lookup));
 	return 0;
 }
arch/mips/bcm47xx/setup.c +1 -1
index 247be207f..de426a474 100644
@@ -282,7 +282,7 @@ static int __init bcm47xx_register_bus_complete(void)
 	bcm47xx_leds_register();
 	bcm47xx_workarounds();
 
-	fixed_phy_add(PHY_POLL, 0, &bcm47xx_fixed_phy_status);
+	fixed_phy_add(0, &bcm47xx_fixed_phy_status);
 	return 0;
 }
 device_initcall(bcm47xx_register_bus_complete);
drivers/net/phy/fixed_phy.c +2 -3
index c91adf246..34a71f223 100644
@@ -160,10 +160,9 @@ static int fixed_phy_add_gpiod(unsigned int irq, int phy_addr,
 	return 0;
 }
 
-int fixed_phy_add(unsigned int irq, int phy_addr,
-		  struct fixed_phy_status *status)
+int fixed_phy_add(int phy_addr, struct fixed_phy_status *status)
 {
-	return fixed_phy_add_gpiod(irq, phy_addr, status, NULL);
+	return fixed_phy_add_gpiod(PHY_POLL, phy_addr, status, NULL);
 }
 EXPORT_SYMBOL_GPL(fixed_phy_add);
 
include/linux/phy_fixed.h +2 -3
index 3392c09b5..316bb4ded 100644
@@ -17,8 +17,7 @@ struct net_device;
 
 #if IS_ENABLED(CONFIG_FIXED_PHY)
 extern int fixed_phy_change_carrier(struct net_device *dev, bool new_carrier);
-extern int fixed_phy_add(unsigned int irq, int phy_id,
-			 struct fixed_phy_status *status);
+int fixed_phy_add(int phy_id, struct fixed_phy_status *status);
 extern struct phy_device *fixed_phy_register(unsigned int irq,
 					     struct fixed_phy_status *status,
 					     struct device_node *np);
@@ -28,7 +27,7 @@ extern int fixed_phy_set_link_update(struct phy_device *phydev,
 			int (*link_update)(struct net_device *,
 					   struct fixed_phy_status *));
 #else
-static inline int fixed_phy_add(unsigned int irq, int phy_id,
+static inline int fixed_phy_add(int phy_id,
 				struct fixed_phy_status *status)
 {
 	return -ENODEV;
Signature · 1 line
2.49.0
author maintainer
#5 lore raw

PATCH 2/3 net: phy: fixed_phy: remove irq argument from fixed_phy_register

In reply to Heiner Kallweit

All callers pass PHY_POLL, therefore remove irq argument from fixed_phy_register().

Note: I keep the irq argument in fixed_phy_add_gpiod() for now, for the case that somebody may want to use a GPIO interrupt in the future, by e.g. adding a call to fwnode_irq_get() to fixed_phy_get_gpiod().

---
 drivers/net/dsa/dsa_loop.c                   |  2 +-
 drivers/net/ethernet/broadcom/bgmac.c        |  2 +-
 drivers/net/ethernet/broadcom/genet/bcmmii.c |  2 +-
 drivers/net/ethernet/faraday/ftgmac100.c     |  2 +-
 drivers/net/mdio/of_mdio.c                   |  2 +-
 drivers/net/phy/fixed_phy.c                  |  5 ++---
 drivers/net/usb/lan78xx.c                    |  2 +-
 include/linux/phy_fixed.h                    | 11 +++++------
 8 files changed, 13 insertions(+), 15 deletions(-)
drivers/net/dsa/dsa_loop.c +1 -1
index adbab544c..d8a35f25a 100644
@@ -405,7 +405,7 @@ static int __init dsa_loop_init(void)
 	unsigned int i, ret;
 
 	for (i = 0; i < NUM_FIXED_PHYS; i++)
-		phydevs[i] = fixed_phy_register(PHY_POLL, &status, NULL);
+		phydevs[i] = fixed_phy_register(&status, NULL);
 
 	ret = mdio_driver_register(&dsa_loop_drv);
 	if (ret)
drivers/net/ethernet/broadcom/bgmac.c +1 -1
index a461ec612..3e9c57196 100644
@@ -1446,7 +1446,7 @@ int bgmac_phy_connect_direct(struct bgmac *bgmac)
 	struct phy_device *phy_dev;
 	int err;
 
-	phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
+	phy_dev = fixed_phy_register(&fphy_status, NULL);
 	if (IS_ERR(phy_dev)) {
 		dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
 		return PTR_ERR(phy_dev);
drivers/net/ethernet/broadcom/genet/bcmmii.c +1 -1
index 71c619d2b..b6437ba7a 100644
@@ -625,7 +625,7 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
 			.asym_pause = 0,
 		};
 
-		phydev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
+		phydev = fixed_phy_register(&fphy_status, NULL);
 		if (IS_ERR(phydev)) {
 			dev_err(kdev, "failed to register fixed PHY device\n");
 			return PTR_ERR(phydev);
drivers/net/ethernet/faraday/ftgmac100.c +1 -1
index 17ec35e75..a98d5af3f 100644
@@ -1906,7 +1906,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
 			goto err_phy_connect;
 		}
 
-		phydev = fixed_phy_register(PHY_POLL, &ncsi_phy_status, np);
+		phydev = fixed_phy_register(&ncsi_phy_status, np);
 		if (IS_ERR(phydev)) {
 			dev_err(&pdev->dev, "failed to register fixed PHY device\n");
 			err = PTR_ERR(phydev);
drivers/net/mdio/of_mdio.c +1 -1
index 2f4fc664d..98f667b12 100644
@@ -458,7 +458,7 @@ int of_phy_register_fixed_link(struct device_node *np)
 	return -ENODEV;
 
 register_phy:
-	return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, np));
+	return PTR_ERR_OR_ZERO(fixed_phy_register(&status, np));
 }
 EXPORT_SYMBOL(of_phy_register_fixed_link);
 
drivers/net/phy/fixed_phy.c +2 -3
index 34a71f223..ea002a137 100644
@@ -222,8 +222,7 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
 }
 #endif
 
-struct phy_device *fixed_phy_register(unsigned int irq,
-				      struct fixed_phy_status *status,
+struct phy_device *fixed_phy_register(struct fixed_phy_status *status,
 				      struct device_node *np)
 {
 	struct fixed_mdio_bus *fmb = &platform_fmb;
@@ -245,7 +244,7 @@ struct phy_device *fixed_phy_register(unsigned int irq,
 	if (phy_addr < 0)
 		return ERR_PTR(phy_addr);
 
-	ret = fixed_phy_add_gpiod(irq, phy_addr, status, gpiod);
+	ret = fixed_phy_add_gpiod(PHY_POLL, phy_addr, status, gpiod);
 	if (ret < 0) {
 		ida_free(&phy_fixed_ida, phy_addr);
 		return ERR_PTR(ret);
drivers/net/usb/lan78xx.c +1 -1
index 8c2488563..759dab980 100644
@@ -2639,7 +2639,7 @@ static struct phy_device *lan78xx_register_fixed_phy(struct lan78xx_net *dev)
 	netdev_info(dev->net,
 		    "No PHY found on LAN7801 – registering fixed PHY (e.g. EVB-KSZ9897-1)\n");
 
-	return fixed_phy_register(PHY_POLL, &fphy_status, NULL);
+	return fixed_phy_register(&fphy_status, NULL);
 }
 
 /**
include/linux/phy_fixed.h +5 -6
index 316bb4ded..634149a73 100644
@@ -18,9 +18,8 @@ struct net_device;
 #if IS_ENABLED(CONFIG_FIXED_PHY)
 extern int fixed_phy_change_carrier(struct net_device *dev, bool new_carrier);
 int fixed_phy_add(int phy_id, struct fixed_phy_status *status);
-extern struct phy_device *fixed_phy_register(unsigned int irq,
-					     struct fixed_phy_status *status,
-					     struct device_node *np);
+struct phy_device *fixed_phy_register(struct fixed_phy_status *status,
+				      struct device_node *np);
 
 extern void fixed_phy_unregister(struct phy_device *phydev);
 extern int fixed_phy_set_link_update(struct phy_device *phydev,
@@ -32,9 +31,9 @@ static inline int fixed_phy_add(int phy_id,
 {
 	return -ENODEV;
 }
-static inline struct phy_device *fixed_phy_register(unsigned int irq,
-						struct fixed_phy_status *status,
-						struct device_node *np)
+static inline struct phy_device *
+fixed_phy_register(struct fixed_phy_status *status,
+		   struct device_node *np)
 {
 	return ERR_PTR(-ENODEV);
 }
Signature · 1 line
2.49.0
author maintainer
#8 lore raw

PATCH 3/3 net: phy: fixed_phy: constify status argument where possible

In reply to Heiner Kallweit

Constify the passed struct fixed_phy_status *status where possible.

---
 drivers/net/phy/fixed_phy.c | 6 +++---
 include/linux/phy_fixed.h   | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/phy/fixed_phy.c +3 -3
index ea002a137..033656d57 100644
@@ -131,7 +131,7 @@ int fixed_phy_set_link_update(struct phy_device *phydev,
 EXPORT_SYMBOL_GPL(fixed_phy_set_link_update);
 
 static int fixed_phy_add_gpiod(unsigned int irq, int phy_addr,
-			       struct fixed_phy_status *status,
+			       const struct fixed_phy_status *status,
 			       struct gpio_desc *gpiod)
 {
 	int ret;
@@ -160,7 +160,7 @@ static int fixed_phy_add_gpiod(unsigned int irq, int phy_addr,
 	return 0;
 }
 
-int fixed_phy_add(int phy_addr, struct fixed_phy_status *status)
+int fixed_phy_add(int phy_addr, const struct fixed_phy_status *status)
 {
 	return fixed_phy_add_gpiod(PHY_POLL, phy_addr, status, NULL);
 }
@@ -222,7 +222,7 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
 }
 #endif
 
-struct phy_device *fixed_phy_register(struct fixed_phy_status *status,
+struct phy_device *fixed_phy_register(const struct fixed_phy_status *status,
 				      struct device_node *np)
 {
 	struct fixed_mdio_bus *fmb = &platform_fmb;
include/linux/phy_fixed.h +4 -4
index 634149a73..5399b9e41 100644
@@ -17,8 +17,8 @@ struct net_device;
 
 #if IS_ENABLED(CONFIG_FIXED_PHY)
 extern int fixed_phy_change_carrier(struct net_device *dev, bool new_carrier);
-int fixed_phy_add(int phy_id, struct fixed_phy_status *status);
-struct phy_device *fixed_phy_register(struct fixed_phy_status *status,
+int fixed_phy_add(int phy_id, const struct fixed_phy_status *status);
+struct phy_device *fixed_phy_register(const struct fixed_phy_status *status,
 				      struct device_node *np);
 
 extern void fixed_phy_unregister(struct phy_device *phydev);
@@ -27,12 +27,12 @@ extern int fixed_phy_set_link_update(struct phy_device *phydev,
 					   struct fixed_phy_status *));
 #else
 static inline int fixed_phy_add(int phy_id,
-				struct fixed_phy_status *status)
+				const struct fixed_phy_status *status)
 {
 	return -ENODEV;
 }
 static inline struct phy_device *
-fixed_phy_register(struct fixed_phy_status *status,
+fixed_phy_register(const struct fixed_phy_status *status,
 		   struct device_node *np)
 {
 	return ERR_PTR(-ENODEV);
Signature · 1 line
2.49.0
reviewer Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH net-next 2/3] net: phy: fixed_phy: remove irq argument from fixed_phy_register

In reply to Heiner Kallweit
Quoted 9 lines · Heiner Kallweit

All callers pass PHY_POLL, therefore remove irq argument from fixed_phy_register().

Note: I keep the irq argument in fixed_phy_add_gpiod() for now, for the case that somebody may want to use a GPIO interrupt in the future, by e.g. adding a call to fwnode_irq_get() to fixed_phy_get_gpiod().

maintainer Reviewed-by on v1 2/3
#7 lore raw

Re: [PATCH net-next 2/3] net: phy: fixed_phy: remove irq argument from fixed_phy_register

In reply to Heiner Kallweit
Quoted 9 lines · Heiner Kallweit

All callers pass PHY_POLL, therefore remove irq argument from fixed_phy_register().

Note: I keep the irq argument in fixed_phy_add_gpiod() for now, for the case that somebody may want to use a GPIO interrupt in the future, by e.g. adding a call to fwnode_irq_get() to fixed_phy_get_gpiod().

Signature · 1 line
Florian
maintainer Acked-by on v1 1/3
#4 lore raw

Re: [PATCH net-next 1/3] net: phy: fixed_phy: remove irq argument from fixed_phy_add

In reply to Heiner Kallweit

Hi Heiner,

Quoted 16 lines · Heiner Kallweit

All callers pass PHY_POLL, therefore remove irq argument from fixed_phy_add().

---
  arch/m68k/coldfire/m5272.c  | 2 +-
  arch/mips/bcm47xx/setup.c   | 2 +-
  drivers/net/phy/fixed_phy.c | 5 ++---
  include/linux/phy_fixed.h   | 5 ++---
  4 files changed, 6 insertions(+), 8 deletions(-)
arch/m68k/coldfire/m5272.c +0 -0
index 734dab657..5b70dfdab 100644

arch/m68k/coldfire/m5272.c static struct fixed_phy_status nettel_fixed_phy_status __initdata = { · line 125

Quoted 8 lines
arch/m68k/coldfire/m5272.c +1 -1
@@ -119,7 +119,7 @@ static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
  static int __init init_BSP(void)
  {
  	m5272_uarts_init();
-	fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
+	fixed_phy_add(0, &nettel_fixed_phy_status);
  	clkdev_add_table(m5272_clk_lookup, ARRAY_SIZE(m5272_clk_lookup));
  	return 0;
  }

Regards
Greg

Quoted 53 lines
arch/mips/bcm47xx/setup.c +1 -1
index 247be207f..de426a474 100644
@@ -282,7 +282,7 @@ static int __init bcm47xx_register_bus_complete(void)
  	bcm47xx_leds_register();
  	bcm47xx_workarounds();
 
-	fixed_phy_add(PHY_POLL, 0, &bcm47xx_fixed_phy_status);
+	fixed_phy_add(0, &bcm47xx_fixed_phy_status);
  	return 0;
  }
  device_initcall(bcm47xx_register_bus_complete);
drivers/net/phy/fixed_phy.c +2 -3
index c91adf246..34a71f223 100644
@@ -160,10 +160,9 @@ static int fixed_phy_add_gpiod(unsigned int irq, int phy_addr,
  	return 0;
  }
 
-int fixed_phy_add(unsigned int irq, int phy_addr,
-		  struct fixed_phy_status *status)
+int fixed_phy_add(int phy_addr, struct fixed_phy_status *status)
  {
-	return fixed_phy_add_gpiod(irq, phy_addr, status, NULL);
+	return fixed_phy_add_gpiod(PHY_POLL, phy_addr, status, NULL);
  }
  EXPORT_SYMBOL_GPL(fixed_phy_add);
 
include/linux/phy_fixed.h +2 -3
index 3392c09b5..316bb4ded 100644
@@ -17,8 +17,7 @@ struct net_device;
 
  #if IS_ENABLED(CONFIG_FIXED_PHY)
  extern int fixed_phy_change_carrier(struct net_device *dev, bool new_carrier);
-extern int fixed_phy_add(unsigned int irq, int phy_id,
-			 struct fixed_phy_status *status);
+int fixed_phy_add(int phy_id, struct fixed_phy_status *status);
  extern struct phy_device *fixed_phy_register(unsigned int irq,
  					     struct fixed_phy_status *status,
  					     struct device_node *np);
@@ -28,7 +27,7 @@ extern int fixed_phy_set_link_update(struct phy_device *phydev,
  			int (*link_update)(struct net_device *,
  					   struct fixed_phy_status *));
  #else
-static inline int fixed_phy_add(unsigned int irq, int phy_id,
+static inline int fixed_phy_add(int phy_id,
  				struct fixed_phy_status *status)
  {
  	return -ENODEV;
#11 lore raw
In reply to Heiner Kallweit
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 10 lines · On Sat, 17 May 2025 22:33:23 +0200 you wrote:

This series includes two types of changes:
- All callers pass PHY_POLL, therefore remove irq argument
- constify the passed struct fixed_phy_status *status

Heiner Kallweit (3):
net: phy: fixed_phy: remove irq argument from fixed_phy_add
net: phy: fixed_phy: remove irq argument from fixed_phy_register
net: phy: fixed_phy: constify status argument where possible

[...]

Here is the summary with links:
- [net-next,1/3] net: phy: fixed_phy: remove irq argument from fixed_phy_add

    https://git.kernel.org/netdev/net-next/c/3f1716ee0f6c
  - [net-next,2/3] net: phy: fixed_phy: remove irq argument from fixed_phy_register
    https://git.kernel.org/netdev/net-next/c/d23b4af5df39
  - [net-next,3/3] net: phy: fixed_phy: constify status argument where possible
    https://git.kernel.org/netdev/net-next/c/4ba1c5bb4811

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html