diff options
author | Guenter Roeck <linux@roeck-us.net> | 2015-02-17 12:36:22 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-20 15:29:49 -0500 |
commit | 54da5a8be3c1e924c35480eb44c6e9b275f6444e (patch) | |
tree | 0b30ead04b8db4b2cd0ce246b60483ef3ae55657 /drivers/net/phy | |
parent | fba04a9e0c869498889b6445fd06cbe7da9bb834 (diff) |
net: phy: Fix verification of EEE support in phy_init_eee
phy_init_eee uses phy_find_setting(phydev->speed, phydev->duplex)
to find a valid entry in the settings array for the given speed
and duplex value. For full duplex 1000baseT, this will return
the first matching entry, which is the entry for 1000baseKX_Full.
If the phy eee does not support 1000baseKX_Full, this entry will not
match, causing phy_init_eee to fail for no good reason.
Fixes: 9a9c56cb34e6 ("net: phy: fix a bug when verify the EEE support")
Fixes: 3e7077067e80c ("phy: Expand phy speed/duplex settings array")
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/phy.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index cdcac6aa4260..52cd8db2c57d 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -236,6 +236,25 @@ static inline unsigned int phy_find_valid(unsigned int idx, u32 features) | |||
236 | } | 236 | } |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * phy_check_valid - check if there is a valid PHY setting which matches | ||
240 | * speed, duplex, and feature mask | ||
241 | * @speed: speed to match | ||
242 | * @duplex: duplex to match | ||
243 | * @features: A mask of the valid settings | ||
244 | * | ||
245 | * Description: Returns true if there is a valid setting, false otherwise. | ||
246 | */ | ||
247 | static inline bool phy_check_valid(int speed, int duplex, u32 features) | ||
248 | { | ||
249 | unsigned int idx; | ||
250 | |||
251 | idx = phy_find_valid(phy_find_setting(speed, duplex), features); | ||
252 | |||
253 | return settings[idx].speed == speed && settings[idx].duplex == duplex && | ||
254 | (settings[idx].setting & features); | ||
255 | } | ||
256 | |||
257 | /** | ||
239 | * phy_sanitize_settings - make sure the PHY is set to supported speed and duplex | 258 | * phy_sanitize_settings - make sure the PHY is set to supported speed and duplex |
240 | * @phydev: the target phy_device struct | 259 | * @phydev: the target phy_device struct |
241 | * | 260 | * |
@@ -1045,7 +1064,6 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) | |||
1045 | int eee_lp, eee_cap, eee_adv; | 1064 | int eee_lp, eee_cap, eee_adv; |
1046 | u32 lp, cap, adv; | 1065 | u32 lp, cap, adv; |
1047 | int status; | 1066 | int status; |
1048 | unsigned int idx; | ||
1049 | 1067 | ||
1050 | /* Read phy status to properly get the right settings */ | 1068 | /* Read phy status to properly get the right settings */ |
1051 | status = phy_read_status(phydev); | 1069 | status = phy_read_status(phydev); |
@@ -1077,8 +1095,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) | |||
1077 | 1095 | ||
1078 | adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); | 1096 | adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); |
1079 | lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); | 1097 | lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); |
1080 | idx = phy_find_setting(phydev->speed, phydev->duplex); | 1098 | if (!phy_check_valid(phydev->speed, phydev->duplex, lp & adv)) |
1081 | if (!(lp & adv & settings[idx].setting)) | ||
1082 | goto eee_exit_err; | 1099 | goto eee_exit_err; |
1083 | 1100 | ||
1084 | if (clk_stop_enable) { | 1101 | if (clk_stop_enable) { |