net: phy: broadcom: Only advertise EEE for supported modes

commit c056d480b4 upstream

We should not be advertising EEE for modes that we do not support,
correct that oversight by looking at the PHY device supported linkmodes.

Fixes: 99cec8a4dd ("net: phy: broadcom: Allow enabling or disabling of EEE")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Florian Fainelli
2021-04-12 16:30:14 -07:00
committed by Greg Kroah-Hartman
parent 4f17a45f8e
commit 8872a0d949

View File

@ -198,7 +198,7 @@ EXPORT_SYMBOL_GPL(bcm_phy_enable_apd);
int bcm_phy_set_eee(struct phy_device *phydev, bool enable) int bcm_phy_set_eee(struct phy_device *phydev, bool enable)
{ {
int val; int val, mask = 0;
/* Enable EEE at PHY level */ /* Enable EEE at PHY level */
val = phy_read_mmd(phydev, MDIO_MMD_AN, BRCM_CL45VEN_EEE_CONTROL); val = phy_read_mmd(phydev, MDIO_MMD_AN, BRCM_CL45VEN_EEE_CONTROL);
@ -217,10 +217,15 @@ int bcm_phy_set_eee(struct phy_device *phydev, bool enable)
if (val < 0) if (val < 0)
return val; return val;
if (phydev->supported & SUPPORTED_1000baseT_Full)
mask |= MDIO_EEE_1000T;
if (phydev->supported & SUPPORTED_100baseT_Full)
mask |= MDIO_EEE_100TX;
if (enable) if (enable)
val |= (MDIO_EEE_100TX | MDIO_EEE_1000T); val |= mask;
else else
val &= ~(MDIO_EEE_100TX | MDIO_EEE_1000T); val &= ~mask;
phy_write_mmd(phydev, MDIO_MMD_AN, BCM_CL45VEN_EEE_ADV, (u32)val); phy_write_mmd(phydev, MDIO_MMD_AN, BCM_CL45VEN_EEE_ADV, (u32)val);