netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch,
	davem@davemloft.net
Cc: netdev@vger.kernel.org, Vladimir Oltean <olteanv@gmail.com>
Subject: [PATCH net 2/2] net: dsa: sja1105: Fix link speed not working at 100 Mbps and below
Date: Sat,  1 Jun 2019 13:37:35 +0300	[thread overview]
Message-ID: <20190601103735.27506-3-olteanv@gmail.com> (raw)
In-Reply-To: <20190601103735.27506-1-olteanv@gmail.com>

The hardware values for link speed are held in the sja1105_speed_t enum.
However they do not increase in the order that sja1105_get_speed_cfg was
iterating over them (basically from SJA1105_SPEED_AUTO - 0 - to
SJA1105_SPEED_1000MBPS - 1 - skipping the other two).

Change the iteration from going through the enum values to going through
the sja1105_speed array, which makes sure that all elements are visited
regardless of underlying ordering.

Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch")
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
 drivers/net/dsa/sja1105/sja1105_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 12b1af52d84b..c3eab40b0500 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -716,7 +716,7 @@ static sja1105_speed_t sja1105_get_speed_cfg(unsigned int speed_mbps)
 {
 	int i;
 
-	for (i = SJA1105_SPEED_AUTO; i <= SJA1105_SPEED_1000MBPS; i++)
+	for (i = 0; i < ARRAY_SIZE(sja1105_speed); i++)
 		if (sja1105_speed[i] == speed_mbps)
 			return i;
 	return SJA1105_SPEED_INVALID;
-- 
2.17.1


      parent reply	other threads:[~2019-06-01 10:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-01 10:37 [PATCH net 0/2] Fix link speed handling for SJA1105 DSA driver Vladimir Oltean
2019-06-01 10:37 ` [PATCH net 1/2] net: dsa: sja1105: Force a negative value for enum sja1105_speed_t Vladimir Oltean
2019-06-01 16:03   ` Andrew Lunn
2019-06-01 20:30     ` Vladimir Oltean
2019-06-01 21:36       ` Andrew Lunn
2019-06-01 10:37 ` Vladimir Oltean [this message]

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=20190601103735.27506-3-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).