OSDN Git Service

net: phy: simplify phy_supported_speeds()
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 13 Apr 2017 15:49:20 +0000 (16:49 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Apr 2017 17:25:07 +0000 (13:25 -0400)
Simplify the loop in phy_supported_speeds().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy.c

index 00280d4..6afbd97 100644 (file)
@@ -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;
 }