linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg
@ 2018-07-23 15:06 Camelia Groza
  2018-07-25 14:24 ` Andrew Lunn
  2018-07-25 20:03 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Camelia Groza @ 2018-07-23 15:06 UTC (permalink / raw)
  To: andrew, f.fainelli, rmk+kernel, davem; +Cc: netdev, linux-kernel, Camelia Groza

genphy_config_aneg() should be called only by PHYs that implement
the Clause 22 register set. Prevent Clause 45 PHYs that don't implement
the register set from calling the genphy function.

Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
 drivers/net/phy/phy.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index efa0a3c..6049652 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -471,8 +471,14 @@ static int phy_config_aneg(struct phy_device *phydev)
 {
 	if (phydev->drv->config_aneg)
 		return phydev->drv->config_aneg(phydev);
-	else
-		return genphy_config_aneg(phydev);
+
+	/* Clause 45 PHYs that don't implement Clause 22 registers are not
+	 * allowed to call genphy_config_aneg()
+	 */
+	if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0)))
+		return -EOPNOTSUPP;
+
+	return genphy_config_aneg(phydev);
 }
 
 /**
-- 
1.9.1


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

* Re: [PATCH net-next] net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg
  2018-07-23 15:06 [PATCH net-next] net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg Camelia Groza
@ 2018-07-25 14:24 ` Andrew Lunn
  2018-07-25 20:03 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2018-07-25 14:24 UTC (permalink / raw)
  To: Camelia Groza; +Cc: f.fainelli, rmk+kernel, davem, netdev, linux-kernel

On Mon, Jul 23, 2018 at 06:06:15PM +0300, Camelia Groza wrote:
> genphy_config_aneg() should be called only by PHYs that implement
> the Clause 22 register set. Prevent Clause 45 PHYs that don't implement
> the register set from calling the genphy function.
> 
> Signed-off-by: Camelia Groza <camelia.groza@nxp.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next] net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg
  2018-07-23 15:06 [PATCH net-next] net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg Camelia Groza
  2018-07-25 14:24 ` Andrew Lunn
@ 2018-07-25 20:03 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-07-25 20:03 UTC (permalink / raw)
  To: camelia.groza; +Cc: andrew, f.fainelli, rmk+kernel, netdev, linux-kernel

From: Camelia Groza <camelia.groza@nxp.com>
Date: Mon, 23 Jul 2018 18:06:15 +0300

> genphy_config_aneg() should be called only by PHYs that implement
> the Clause 22 register set. Prevent Clause 45 PHYs that don't implement
> the register set from calling the genphy function.
> 
> Signed-off-by: Camelia Groza <camelia.groza@nxp.com>

Applied, thank you.

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

end of thread, other threads:[~2018-07-25 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 15:06 [PATCH net-next] net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg Camelia Groza
2018-07-25 14:24 ` Andrew Lunn
2018-07-25 20:03 ` David Miller

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