]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: phy: fixed: let fixed_phy_add always use addr 0 and remove return value
authorHeiner Kallweit <hkallweit1@gmail.com>
Fri, 22 Aug 2025 20:36:11 +0000 (22:36 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 27 Aug 2025 00:19:02 +0000 (17:19 -0700)
We have only two users of fixed_phy_add(), both use address 0 and
ignore the return value. So simplify fixed_phy_add() accordingly.

Whilst at it, constify the fixed_phy_status configs.

Note:
fixed_phy_add() is a legacy function which shouldn't be used in new
code, as it's use may be problematic:
- No check whether a fixed phy exists already at the given address
- If fixed_phy_register() is called afterwards by any other driver,
  then it will also use phy_addr 0, because fixed_phy_add() ignores
  the ida which manages address assignment
Drivers using a fixed phy created by fixed_phy_add() in platform code,
should dynamically create a fixed phy with fixed_phy_register()
instead.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/762700e5-a0b1-41af-aa03-929822a39475@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
arch/m68k/coldfire/m5272.c
arch/mips/bcm47xx/setup.c
drivers/net/phy/fixed_phy.c
include/linux/phy_fixed.h

index 5b70dfdab368bc9ec13f7094c81b64b8ef9ec89c..918e2a3236c5bb592128c6c9b04e402fb71d0c11 100644 (file)
@@ -108,7 +108,7 @@ void __init config_BSP(char *commandp, int size)
  * an ethernet switch. In this case we need to use the fixed phy type,
  * and we need to declare it early in boot.
  */
-static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
+static const struct fixed_phy_status nettel_fixed_phy_status __initconst = {
        .link   = 1,
        .speed  = 100,
        .duplex = 0,
@@ -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(0, &nettel_fixed_phy_status);
+       fixed_phy_add(&nettel_fixed_phy_status);
        clkdev_add_table(m5272_clk_lookup, ARRAY_SIZE(m5272_clk_lookup));
        return 0;
 }
index de426a474b5b2420f560ba934ae37074e8217909..a93a4266dc1efe3de15f13f50973fe31da71b322 100644 (file)
@@ -256,7 +256,7 @@ static int __init bcm47xx_cpu_fixes(void)
 }
 arch_initcall(bcm47xx_cpu_fixes);
 
-static struct fixed_phy_status bcm47xx_fixed_phy_status __initdata = {
+static const struct fixed_phy_status bcm47xx_fixed_phy_status __initconst = {
        .link   = 1,
        .speed  = SPEED_100,
        .duplex = DUPLEX_FULL,
@@ -282,7 +282,7 @@ static int __init bcm47xx_register_bus_complete(void)
        bcm47xx_leds_register();
        bcm47xx_workarounds();
 
-       fixed_phy_add(0, &bcm47xx_fixed_phy_status);
+       fixed_phy_add(&bcm47xx_fixed_phy_status);
        return 0;
 }
 device_initcall(bcm47xx_register_bus_complete);
index 8ad49dc1105deb994630b47c95f57e732ac32269..5a1badb9bbabbb4e36f468fa702ba9df04b02705 100644 (file)
@@ -158,9 +158,9 @@ static int fixed_phy_add_gpiod(unsigned int irq, int phy_addr,
        return 0;
 }
 
-int fixed_phy_add(int phy_addr, const struct fixed_phy_status *status)
+void fixed_phy_add(const struct fixed_phy_status *status)
 {
-       return fixed_phy_add_gpiod(PHY_POLL, phy_addr, status, NULL);
+       fixed_phy_add_gpiod(PHY_POLL, 0, status, NULL);
 }
 EXPORT_SYMBOL_GPL(fixed_phy_add);
 
index 5399b9e41e35594145c844d116611146cecb3442..6227a1bdefecede5459bbf6d99050b0ad9bfcb06 100644 (file)
@@ -17,7 +17,7 @@ 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, const struct fixed_phy_status *status);
+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);
 
@@ -26,11 +26,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(int phy_id,
-                               const struct fixed_phy_status *status)
-{
-       return -ENODEV;
-}
+static inline void fixed_phy_add(const struct fixed_phy_status *status) {}
 static inline struct phy_device *
 fixed_phy_register(const struct fixed_phy_status *status,
                   struct device_node *np)