Commit 7a4cecf7 authored by Giuseppe CAVALLARO's avatar Giuseppe CAVALLARO Committed by David S. Miller

phy: fix EEE checks inside the phy_init_eee.

According to the Std 802.3az if the EEE Adv (Reg 7.60), Link partner ability
(Reg 7.61) and EEE capability (Register 3.20) bits return 0 this  means no EEE
is supported. So this patch fixes the checks inside the phy_init_eee function.
Signed-off-by: default avatarNandini Sharma <nandini.sharma@st.com>
Signed-off-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2d39d120
...@@ -1036,31 +1036,31 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) ...@@ -1036,31 +1036,31 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
/* First check if the EEE ability is supported */ /* First check if the EEE ability is supported */
eee_cap = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE, eee_cap = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE,
MDIO_MMD_PCS, phydev->addr); MDIO_MMD_PCS, phydev->addr);
if (eee_cap < 0) if (eee_cap <= 0)
return eee_cap; goto eee_exit_err;
cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap); cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
if (!cap) if (!cap)
return -EPROTONOSUPPORT; goto eee_exit_err;
/* Check which link settings negotiated and verify it in /* Check which link settings negotiated and verify it in
* the EEE advertising registers. * the EEE advertising registers.
*/ */
eee_lp = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE, eee_lp = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE,
MDIO_MMD_AN, phydev->addr); MDIO_MMD_AN, phydev->addr);
if (eee_lp < 0) if (eee_lp <= 0)
return eee_lp; goto eee_exit_err;
eee_adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, eee_adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
MDIO_MMD_AN, phydev->addr); MDIO_MMD_AN, phydev->addr);
if (eee_adv < 0) if (eee_adv <= 0)
return eee_adv; goto eee_exit_err;
adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
idx = phy_find_setting(phydev->speed, phydev->duplex); idx = phy_find_setting(phydev->speed, phydev->duplex);
if (!(lp & adv & settings[idx].setting)) if (!(lp & adv & settings[idx].setting))
return -EPROTONOSUPPORT; goto eee_exit_err;
if (clk_stop_enable) { if (clk_stop_enable) {
/* Configure the PHY to stop receiving xMII /* Configure the PHY to stop receiving xMII
...@@ -1080,7 +1080,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) ...@@ -1080,7 +1080,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
return 0; /* EEE supported */ return 0; /* EEE supported */
} }
eee_exit_err:
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
} }
EXPORT_SYMBOL(phy_init_eee); EXPORT_SYMBOL(phy_init_eee);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment