diff mbox series

[net,2/2] net: dsa: sja1105: Fix link speed not working at 100 Mbps and below

Message ID 20190601103735.27506-3-olteanv@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Fix link speed handling for SJA1105 DSA driver | expand

Commit Message

Vladimir Oltean June 1, 2019, 10:37 a.m. UTC
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 mbox series

Patch

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;