netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] net: phy: broadcom: Correct BCM5221 PHY model detection failure
@ 2025-03-17  3:50 Jim Liu
  2025-03-17  8:47 ` Michal Swiatkowski
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Liu @ 2025-03-17  3:50 UTC (permalink / raw)
  To: JJLIU0, jim.t90615, florian.fainelli, andrew, hkallweit1, kuba,
	linux, edumazet, pabeni
  Cc: netdev, linux-kernel

Use "BRCM_PHY_MODEL" can be applied to the entire 5221 family of PHYs.

Fixes: 3abbd0699b67 (net: phy: broadcom: add support for BCM5221 phy)
Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
---
 drivers/net/phy/broadcom.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 22edb7e4c1a1..3529289e9d13 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -859,7 +859,7 @@ static int brcm_fet_config_init(struct phy_device *phydev)
 		return reg;
 
 	/* Unmask events we are interested in and mask interrupts globally. */
-	if (phydev->phy_id == PHY_ID_BCM5221)
+	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM5221)
 		reg = MII_BRCM_FET_IR_ENABLE |
 		      MII_BRCM_FET_IR_MASK;
 	else
@@ -888,7 +888,7 @@ static int brcm_fet_config_init(struct phy_device *phydev)
 		return err;
 	}
 
-	if (phydev->phy_id != PHY_ID_BCM5221) {
+	if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM5221) {
 		/* Set the LED mode */
 		reg = __phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4);
 		if (reg < 0) {
@@ -1009,7 +1009,7 @@ static int brcm_fet_suspend(struct phy_device *phydev)
 		return err;
 	}
 
-	if (phydev->phy_id == PHY_ID_BCM5221)
+	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM5221)
 		/* Force Low Power Mode with clock enabled */
 		reg = BCM5221_SHDW_AM4_EN_CLK_LPM | BCM5221_SHDW_AM4_FORCE_LPM;
 	else
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] net: phy: broadcom: Correct BCM5221 PHY model detection failure
  2025-03-17  3:50 [PATCH v1] net: phy: broadcom: Correct BCM5221 PHY model detection failure Jim Liu
@ 2025-03-17  8:47 ` Michal Swiatkowski
  2025-03-17 10:28   ` Russell King (Oracle)
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Swiatkowski @ 2025-03-17  8:47 UTC (permalink / raw)
  To: Jim Liu
  Cc: JJLIU0, florian.fainelli, andrew, hkallweit1, kuba, linux,
	edumazet, pabeni, netdev, linux-kernel

On Mon, Mar 17, 2025 at 11:50:05AM +0800, Jim Liu wrote:
> Use "BRCM_PHY_MODEL" can be applied to the entire 5221 family of PHYs.
> 
> Fixes: 3abbd0699b67 (net: phy: broadcom: add support for BCM5221 phy)
> Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
> ---
>  drivers/net/phy/broadcom.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 22edb7e4c1a1..3529289e9d13 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
> @@ -859,7 +859,7 @@ static int brcm_fet_config_init(struct phy_device *phydev)
>  		return reg;
>  
>  	/* Unmask events we are interested in and mask interrupts globally. */
> -	if (phydev->phy_id == PHY_ID_BCM5221)
> +	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM5221)
>  		reg = MII_BRCM_FET_IR_ENABLE |
>  		      MII_BRCM_FET_IR_MASK;
>  	else
> @@ -888,7 +888,7 @@ static int brcm_fet_config_init(struct phy_device *phydev)
>  		return err;
>  	}
>  
> -	if (phydev->phy_id != PHY_ID_BCM5221) {
> +	if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM5221) {
>  		/* Set the LED mode */
>  		reg = __phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4);
>  		if (reg < 0) {
> @@ -1009,7 +1009,7 @@ static int brcm_fet_suspend(struct phy_device *phydev)
>  		return err;
>  	}
>  
> -	if (phydev->phy_id == PHY_ID_BCM5221)
> +	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM5221)
>  		/* Force Low Power Mode with clock enabled */
>  		reg = BCM5221_SHDW_AM4_EN_CLK_LPM | BCM5221_SHDW_AM4_FORCE_LPM;
>  	else
> -- 
> 2.34.1

It will be nice to have wider explanation what it is fixing in commit
message. Is phydev->phy_id different than phydev->driver->phy_id? Looks
like masking isn't crucial as phydev->driver->phy_id is initialized by
PHY_ID_BCM5221 which is already masked.

Anyway, looks fine, thanks.
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] net: phy: broadcom: Correct BCM5221 PHY model detection failure
  2025-03-17  8:47 ` Michal Swiatkowski
@ 2025-03-17 10:28   ` Russell King (Oracle)
  0 siblings, 0 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-03-17 10:28 UTC (permalink / raw)
  To: Michal Swiatkowski
  Cc: Jim Liu, JJLIU0, florian.fainelli, andrew, hkallweit1, kuba,
	edumazet, pabeni, netdev, linux-kernel

On Mon, Mar 17, 2025 at 09:47:37AM +0100, Michal Swiatkowski wrote:
> It will be nice to have wider explanation what it is fixing in commit
> message. Is phydev->phy_id different than phydev->driver->phy_id? Looks
> like masking isn't crucial as phydev->driver->phy_id is initialized by
> PHY_ID_BCM5221 which is already masked.

The two are very different, and this driver just gets it totally wrong.

phydev->phy_id is the ID read from the PHY. It includes the revision
field.

phydev->drv is one of the phy_driver entries at the bottom of the file.
These contain whatever the driver author puts there, which in this
case would be PHY_ID_BCM5221, and PHY_ID_BCM5221 is defined without
the revision number.

So doing the masking is entirely redundant if you're comparing the
drv->phy_id that was initialised with a definition against the same
definition.

As pointed out in my review with v2, there's more problems in this
driver _because_ this has not been understood. In an attempt to get
rid of some of this stuff, I introduced phydev_id_compare() and
phy_id_compare() helpers into core phylib code, but didn't get
around to updating broadcom.c. See my comments against v2.

-- 
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] 3+ messages in thread

end of thread, other threads:[~2025-03-17 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17  3:50 [PATCH v1] net: phy: broadcom: Correct BCM5221 PHY model detection failure Jim Liu
2025-03-17  8:47 ` Michal Swiatkowski
2025-03-17 10:28   ` Russell King (Oracle)

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).