diff options
Diffstat (limited to 'drivers/net/phy/phy.c')
-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) { |