public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux•org.uk>
To: Florian Fainelli <f.fainelli@gmail•com>, Andrew Lunn <andrew@lunn•ch>
Cc: "David S. Miller" <davem@davemloft•net>, netdev@vger•kernel.org
Subject: [PATCH RFC v2 2/2] net: phy: simplify phy_supported_speeds()
Date: Thu, 06 Apr 2017 11:01:31 +0100	[thread overview]
Message-ID: <E1cw4EN-0001FD-Vp@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20170406100033.GA24671@n2100.armlinux.org.uk>

Simplify the loop in phy_supported_speeds().

Signed-off-by: Russell King <rmk+kernel@armlinux•org.uk>
---
 drivers/net/phy/phy.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index b50b6e61aace..f3015e6a52ab 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;
 }
-- 
2.7.4

  parent reply	other threads:[~2017-04-06 10:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 10:00 [PATCH RFC v2 0/2] phylib non-autoneg speed setting Russell King - ARM Linux
2017-04-06 10:01 ` [PATCH RFC v2 1/2] net: phy: improve phylib correctness for non-autoneg settings Russell King
2017-04-06 10:01 ` Russell King [this message]
2017-04-07 20:51 ` [PATCH RFC v2 0/2] phylib non-autoneg speed setting Florian Fainelli
2017-04-13 15:49 ` [PATCH 1/2] net: phy: improve phylib correctness for non-autoneg settings Russell King
2017-04-17 17:25   ` David Miller
2017-04-13 15:49 ` [PATCH 2/2] net: phy: simplify phy_supported_speeds() Russell King
2017-04-17 17:25   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1cw4EN-0001FD-Vp@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux$(echo .)org.uk \
    --cc=andrew@lunn$(echo .)ch \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox