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 <olte...@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