From: Russell King Date: Thu, 13 Apr 2017 15:49:20 +0000 (+0100) Subject: net: phy: simplify phy_supported_speeds() X-Git-Tag: v4.12-rc1~129^2~181 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=786df9c2a4216e64e5b7c321405d706036a76ba3;p=thirdparty%2Fkernel%2Flinux.git net: phy: simplify phy_supported_speeds() Simplify the loop in phy_supported_speeds(). Signed-off-by: Russell King Signed-off-by: David S. Miller --- diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 00280d4eeb563..6afbd973a779b 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -320,17 +320,11 @@ unsigned int phy_supported_speeds(struct phy_device *phy, unsigned int count = 0; unsigned int idx = 0; - for (idx = 0; idx < ARRAY_SIZE(settings) && count < size; idx++) { - if (!(settings[idx].setting & phy->supported)) - continue; - + for (idx = 0; idx < ARRAY_SIZE(settings) && count < size; idx++) /* Assumes settings are grouped by speed */ - if ((count == 0) || - (speeds[count - 1] != settings[idx].speed)) { - speeds[count] = settings[idx].speed; - count++; - } - } + if ((settings[idx].setting & phy->supported) && + (count == 0 || speeds[count - 1] != settings[idx].speed)) + speeds[count++] = settings[idx].speed; return count; }