*/
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
{
- int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
+ int cap, adv;
if (!phydev->drv)
return -EIO;
- /* Mask prohibited EEE modes */
- val &= ~phydev->eee_broken_modes;
+ /* Get Supported EEE */
+ cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
+ if (cap < 0)
+ return cap;
- phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, val);
+ adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
- return 0;
+ /* Mask prohibited EEE modes */
+ adv &= ~phydev->eee_broken_modes;
+
+ return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
}
EXPORT_SYMBOL(phy_ethtool_set_eee);