From: Camelia Groza Date: Mon, 23 Jul 2018 15:06:15 +0000 (+0300) Subject: net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg X-Git-Tag: v5.15~8230^2~266 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34786005eca3b53cffa95d686bf3b7da1305867c;p=platform%2Fkernel%2Flinux-starfive.git net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg 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 Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller --- diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 914fe8e..04780db 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); } /**