net: phy: fixed: let fixed_phy_add always use addr 0 and remove return value
Subsystems (8)
Heiner Kallweit
maintainerPATCH 1/1 net: phy: fixed: let fixed_phy_add always use addr 0 and remove return value
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.
--- arch/m68k/coldfire/m5272.c | 4 ++-- arch/mips/bcm47xx/setup.c | 4 ++-- drivers/net/phy/fixed_phy.c | 4 ++-- include/linux/phy_fixed.h | 8 ++------ 4 files changed, 8 insertions(+), 12 deletions(-)
arch/m68k/coldfire/m5272.c +2 -2
@@ -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 ; }
arch/mips/bcm47xx/setup.c +2 -2
@@ -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);
drivers/net/phy/fixed_phy.c +2 -2
@@ -153,9 +153,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);
include/linux/phy_fixed.h +2 -6
@@ -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)
Signature · 1 line
2.50.1
Hauke Mehrtens
maintainerQuoted 100 lines · Heiner Kallweit
We have only two users of
fixed_phy_add(), both use address 0 and ignore the return value. So simplifyfixed_phy_add()accordingly.Whilst at it, constify the
fixed_phy_statusconfigs.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
- Iffixed_phy_register()is called afterwards by any other driver, then it will also usephy_addr0, becausefixed_phy_add()ignores the ida which manages address assignment
Drivers using a fixed phy created byfixed_phy_add()in platform code, should dynamically create a fixed phy withfixed_phy_register()instead.Signed-off-by Heiner Kallweit <[email protected]>--- arch/m68k/coldfire/m5272.c | 4 ++-- arch/mips/bcm47xx/setup.c | 4 ++-- drivers/net/phy/fixed_phy.c | 4 ++-- include/linux/phy_fixed.h | 8 ++------ 4 files changed, 8 insertions(+), 12 deletions(-)arch/m68k/coldfire/m5272.c +2
-2@@ -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 ; }arch/mips/bcm47xx/setup.c +2
-2@@ -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);drivers/net/phy/fixed_phy.c +2
-2@@ -153,9 +153,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);include/linux/phy_fixed.h +1
-1@@ -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 *));
include/linux/phy_fixed.h extern int fixed_phy_set_link_update(struct phy_device *phydev, · line 32
Quoted 10 lines
include/linux/phy_fixed.h +1
-5#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)
Hi,
I do not use this hardware any more, but Takumi reported that fixed_phy_add() is not working for the PHY registration on brcm47xx any more and we have to use fixed_phy_register(), see:
https://github.com/openwrt/openwrt/pull/19610
Does this need a bigger refactoring anyway?
Hauke
Heiner Kallweit
maintainerQuoted 108 lines · Hauke Mehrtens
Quoted 101 lines · Heiner Kallweit
We have only two users of
fixed_phy_add(), both use address 0 and ignore the return value. So simplifyfixed_phy_add()accordingly.Whilst at it, constify the
fixed_phy_statusconfigs.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
- Iffixed_phy_register()is called afterwards by any other driver, then it will also usephy_addr0, becausefixed_phy_add()ignores the ida which manages address assignment
Drivers using a fixed phy created byfixed_phy_add()in platform code, should dynamically create a fixed phy withfixed_phy_register()instead.Signed-off-by Heiner Kallweit <[email protected]>---
arch/m68k/coldfire/m5272.c | 4 ++--
arch/mips/bcm47xx/setup.c | 4 ++--
drivers/net/phy/fixed_phy.c| 4 ++--
include/linux/phy_fixed.h | 8 ++------4 files changed, 8 insertions(+), 12 deletions(-)arch/m68k/coldfire/m5272.c +2
-2@@ -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; }arch/mips/bcm47xx/setup.c +2
-0@@ -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);drivers/net/phy/fixed_phy.c +2
-1@@ -153,9 +153,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);diff --git
a/include/linux/phy_fixed.hb/include/linux/phy_fixed.hindex5399b9e41..6227a1bde100644include/linux/phy_fixed.h +1
-1@@ -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*)); #elseinclude/linux/phy_fixed.h +1
-5-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) {}Quoted 3 lines
static inline struct
phy_device*fixed_phy_register(const struct fixed_phy_status *status, struct device_node *np)Hi,
Quoted 3 lines
I do not use this hardware any more, but Takumi reported that
fixed_phy_add()is not working for the PHY registration on brcm47xx any more and we have to usefixed_phy_register(), see:
https://github.com/openwrt/openwrt/pull/19610
I suspected already that fixed_phy_add() usage doesn't work any longer, but don't have hw to test. I think bfa54812f0bc ("net: phy: fixed_phy: set phy_mask before calling mdiobus_register()") is to blame.
Reverting this commit or changing the line to fmb->mii_bus->phy_mask = ~1; should fix the problem. Would be great if Takumi could test this.
The cleaner alternative would be:
- remove call to fixed_phy_add() from platform code
- let b44 call fixed_phy_register() if a fixed phy is needed Below is a WIP version of this change.
Quoted 3 lines
Does this need a bigger refactoring anyway?
Hauke
Heiner
--- drivers/net/ethernet/broadcom/Kconfig | 1 + drivers/net/ethernet/broadcom/b44.c | 33 ++++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/ethernet/broadcom/Kconfig +1 -0
@@ -25,6 +25,7 @@ config B44 select SSB select MII select PHYLIB + select FIXED_PHY help If you have a network (Ethernet) controller of this type, say Y or M here.
drivers/net/ethernet/broadcom/b44.c +17 -16
@@ -31,6 +31,7 @@#include <linux/ssb/ssb.h> #include <linux/slab.h> #include <linux/phy.h> +#include <linux/phy_fixed.h> #include <linux/uaccess.h> #include <asm/io.h>
@@ -2233,7 +2234,6 @@ static int b44_register_phy_one(struct b44 *bp)struct mii_bus *mii_bus;struct ssb_device *sdev = bp->sdev;struct phy_device *phydev; -char bus_id[MII_BUS_ID_SIZE +3 ];struct ssb_sprom *sprom = &sdev->bus->sprom;int err;
@@ -2260,27 +2260,26 @@ static int b44_register_phy_one(struct b44 *bp) goto err_out_mdiobus; } -if (!mdiobus_is_registered_device (bp->mii_bus, bp->phy_addr) && - (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO |B44_BOARDFLAG_ADM ))) { - + phydev =mdiobus_get_phy (bp->mii_bus, bp->phy_addr); +if (!phydev && + sprom->boardflags_lo & (B44_BOARDFLAG_ROBO |B44_BOARDFLAG_ADM )) {dev_info (sdev->dev,"could not find PHY at %i, use fixed one\n" , bp->phy_addr); - bp->phy_addr =0 ; -snprintf (bus_id,sizeof (bus_id),PHY_ID_FMT ,"fixed-0" , - bp->phy_addr); - }else { -snprintf (bus_id,sizeof (bus_id),PHY_ID_FMT , mii_bus->id, - bp->phy_addr); + phydev =fixed_phy_register (NULL ,NULL ); +if (!IS_ERR (phydev)) + bp->phy_addr = phydev->mdio.addr; } - phydev =phy_connect (bp->dev, bus_id, &b44_adjust_link, -PHY_INTERFACE_MODE_MII ); -if (IS_ERR (phydev)) { +if (IS_ERR_OR_NULL (phydev)) + err = -ENODEV ; +else + err =phy_connect_direct (bp->dev, phydev, &b44_adjust_link, +PHY_INTERFACE_MODE_MII ); +if (err) {dev_err (sdev->dev,"could not attach PHY at %i\n" , bp->phy_addr); - err =PTR_ERR (phydev); goto err_out_mdiobus_unregister; }
@@ -2293,7 +2292,6 @@ static int b44_register_phy_one(struct b44 *bp)linkmode_copy (phydev->advertising, phydev->supported); bp->old_link =0 ; - bp->phy_addr = phydev->mdio.addr;phy_attached_info (phydev);
@@ -2313,8 +2311,11 @@ static void b44_unregister_phy_one(struct b44 *bp) {struct net_device *dev = bp->dev;struct mii_bus *mii_bus = bp->mii_bus; + struct phy_device *phydev = dev->phydev); -phy_disconnect (dev->phydev); +phy_disconnect (phydev); +if (phy_is_pseudo_fixed_link (phydev)) +fixed_phy_unregister (phydev);mdiobus_unregister (mii_bus);mdiobus_free (mii_bus); }
Signature · 1 line
2.50.1
Heiner Kallweit
maintainerQuoted 109 lines · Heiner Kallweit
Quoted 108 lines · Hauke Mehrtens
Quoted 101 lines · Heiner Kallweit
We have only two users of
fixed_phy_add(), both use address 0 and ignore the return value. So simplifyfixed_phy_add()accordingly.Whilst at it, constify the
fixed_phy_statusconfigs.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
- Iffixed_phy_register()is called afterwards by any other driver, then it will also usephy_addr0, becausefixed_phy_add()ignores the ida which manages address assignment
Drivers using a fixed phy created byfixed_phy_add()in platform code, should dynamically create a fixed phy withfixed_phy_register()instead.Signed-off-by Heiner Kallweit <[email protected]>---
arch/m68k/coldfire/m5272.c | 4 ++--
arch/mips/bcm47xx/setup.c | 4 ++--
drivers/net/phy/fixed_phy.c| 4 ++--
include/linux/phy_fixed.h | 8 ++------4 files changed, 8 insertions(+), 12 deletions(-)arch/m68k/coldfire/m5272.c +2
-2@@ -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; }arch/mips/bcm47xx/setup.c +2
-0@@ -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);drivers/net/phy/fixed_phy.c +2
-1@@ -153,9 +153,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);diff --git
a/include/linux/phy_fixed.hb/include/linux/phy_fixed.hindex5399b9e41..6227a1bde100644include/linux/phy_fixed.h +1
-1@@ -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*)); #elseinclude/linux/phy_fixed.h +1
-5-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) {}Quoted 3 lines
static inline struct
phy_device*fixed_phy_register(const struct fixed_phy_status *status, struct device_node *np)Hi,
Quoted 9 lines
Quoted 3 lines
I do not use this hardware any more, but Takumi reported that
fixed_phy_add()is not working for the PHY registration on brcm47xx any more and we have to usefixed_phy_register(), see:
https://github.com/openwrt/openwrt/pull/19610I suspected already that
fixed_phy_add()usage doesn't work any longer, but don't have hw to test. I thinkbfa54812f0bc("net: phy:fixed_phy: setphy_maskbefore callingmdiobus_register()") is to blame.
Reverting this commit or changing the line tofmb->mii_bus->phy_mask= ~1; should fix the problem. Would be great if Takumi could test this.
Did you have the chance to test this?
Quoted 110 lines
The cleaner alternative would be:
- remove call tofixed_phy_add()from platform code
- let b44 callfixed_phy_register()if a fixed phy is needed Below is a WIP version of this change.Quoted 3 lines
Does this need a bigger refactoring anyway?
Hauke
Heiner
--- drivers/net/ethernet/broadcom/Kconfig | 1 + drivers/net/ethernet/broadcom/b44.c | 33 ++++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-)drivers/net/ethernet/broadcom/Kconfig +1
-0@@ -25,6 +25,7 @@ config B44 select SSB select MII select PHYLIB + select FIXED_PHY help If you have a network (Ethernet) controller of this type, say Y or M here.drivers/net/ethernet/broadcom/b44.c +17
-16@@ -31,6 +31,7 @@#include <linux/ssb/ssb.h> #include <linux/slab.h> #include <linux/phy.h> +#include <linux/phy_fixed.h> #include <linux/uaccess.h> #include <asm/io.h> @@ -2233,7 +2234,6 @@ static int b44_register_phy_one(struct b44 *bp)struct mii_bus *mii_bus;struct ssb_device *sdev = bp->sdev;struct phy_device *phydev; -char bus_id[MII_BUS_ID_SIZE +3 ];struct ssb_sprom *sprom = &sdev->bus->sprom;int err;@@ -2260,27 +2260,26 @@ static int b44_register_phy_one(struct b44 *bp) goto err_out_mdiobus; } -if (!mdiobus_is_registered_device (bp->mii_bus, bp->phy_addr) && - (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO |B44_BOARDFLAG_ADM ))) { - + phydev =mdiobus_get_phy (bp->mii_bus, bp->phy_addr); +if (!phydev && + sprom->boardflags_lo & (B44_BOARDFLAG_ROBO |B44_BOARDFLAG_ADM )) {dev_info (sdev->dev,"could not find PHY at %i, use fixed one\n" , bp->phy_addr); - bp->phy_addr =0 ; -snprintf (bus_id,sizeof (bus_id),PHY_ID_FMT ,"fixed-0" , - bp->phy_addr); - }else { -snprintf (bus_id,sizeof (bus_id),PHY_ID_FMT , mii_bus->id, - bp->phy_addr); + phydev =fixed_phy_register (NULL ,NULL ); +if (!IS_ERR (phydev)) + bp->phy_addr = phydev->mdio.addr; } - phydev =phy_connect (bp->dev, bus_id, &b44_adjust_link, -PHY_INTERFACE_MODE_MII ); -if (IS_ERR (phydev)) { +if (IS_ERR_OR_NULL (phydev)) + err = -ENODEV ; +else + err =phy_connect_direct (bp->dev, phydev, &b44_adjust_link, +PHY_INTERFACE_MODE_MII ); +if (err) {dev_err (sdev->dev,"could not attach PHY at %i\n" , bp->phy_addr); - err =PTR_ERR (phydev); goto err_out_mdiobus_unregister; }@@ -2293,7 +2292,6 @@ static int b44_register_phy_one(struct b44 *bp)linkmode_copy (phydev->advertising, phydev->supported); bp->old_link =0 ; - bp->phy_addr = phydev->mdio.addr;phy_attached_info (phydev);@@ -2313,8 +2311,11 @@ static void b44_unregister_phy_one(struct b44 *bp) {struct net_device *dev = bp->dev;struct mii_bus *mii_bus = bp->mii_bus; + struct phy_device *phydev = dev->phydev); -phy_disconnect (dev->phydev); +phy_disconnect (phydev); +if (phy_is_pseudo_fixed_link (phydev)) +fixed_phy_unregister (phydev);mdiobus_unregister (mii_bus);mdiobus_free (mii_bus); }
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 16 lines · On Fri, 22 Aug 2025 22:36:11 +0200 you wrote:
We have only two users of
fixed_phy_add(), both use address 0 and ignore the return value. So simplifyfixed_phy_add()accordingly.Whilst at it, constify the
fixed_phy_statusconfigs.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
- Iffixed_phy_register()is called afterwards by any other driver, then it will also usephy_addr0, becausefixed_phy_add()ignores the ida which manages address assignment
Drivers using a fixed phy created byfixed_phy_add()in platform code, should dynamically create a fixed phy withfixed_phy_register()instead.
Quoted 1 line
[...]
Here is the summary with links:
- [net-next] net: phy: fixed: let fixed_phy_add always use addr 0 and remove return value
https://git.kernel.org/netdev/net-next/c/39e94fdce45f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html