From: Colin King <hidden> Date: 2020-05-01 13:47:44
From: Colin Ian King <redacted>
The current logic for speed checking will never set the speed to 10 MBPS
because bmcr & BMCR_SPEED10 is always 0 since BMCR_SPEED10 is 0. Also
the erroneous setting where BMCR_SPEED1000 and BMCR_SPEED100 are both
set causes the speed to be 1000 MBS. Fix this by masking bps and checking
for just the expected settings of BMCR_SPEED1000, BMCR_SPEED100 and
BMCR_SPEED10 and defaulting to the unknown speed otherwise.
Addresses-Coverity: ("Logically dead code")
Fixes: ffe10e679cec ("net: dsa: sja1105: Add support for the SGMII port")
Signed-off-by: Colin Ian King <redacted>
---
drivers/net/dsa/sja1105/sja1105_main.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
From: Walter Harms <hidden> Date: 2020-05-01 18:00:57
IMHO it would be better to use switch case here to improve readability.
switch (bmcr & mask) {
case BMCR_SPEED1000:
speed = SPEED_1000;
break;
case BMCR_SPEED100:
speed = SPEED_100;
break;
case BMCR_SPEED10:
speed = SPEED_10;
break;
default:
speed = SPEED_UNKNOWN
}
jm2c,
wh
btw: an_enabled ? why not !enabled, mich more easy to read
________________________________________
Von: kernel-janitors-owner@vger.kernel.org [off-list ref] im Auftrag von Colin King [off-list ref]
Gesendet: Freitag, 1. Mai 2020 15:43:10
An: Vladimir Oltean; Andrew Lunn; Vivien Didelot; Florian Fainelli; David S . Miller; Russell King; linux-kernel@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org; netdev@vger.kernel.org
Betreff: [PATCH] net: dsa: sja1105: fix speed setting for 10 MBPS
From: Colin Ian King <redacted>
The current logic for speed checking will never set the speed to 10 MBPS
because bmcr & BMCR_SPEED10 is always 0 since BMCR_SPEED10 is 0. Also
the erroneous setting where BMCR_SPEED1000 and BMCR_SPEED100 are both
set causes the speed to be 1000 MBS. Fix this by masking bps and checking
for just the expected settings of BMCR_SPEED1000, BMCR_SPEED100 and
BMCR_SPEED10 and defaulting to the unknown speed otherwise.
Addresses-Coverity: ("Logically dead code")
Fixes: ffe10e679cec ("net: dsa: sja1105: Add support for the SGMII port")
Signed-off-by: Colin Ian King <redacted>
---
drivers/net/dsa/sja1105/sja1105_main.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
From: Russell King - ARM Linux admin <linux@armlinux.org.uk> Date: 2020-05-01 18:37:28
On Fri, May 01, 2020 at 06:00:52PM +0000, Walter Harms wrote:
IMHO it would be better to use switch case here to improve readability.
switch (bmcr & mask) {
case BMCR_SPEED1000:
speed = SPEED_1000;
break;
case BMCR_SPEED100:
speed = SPEED_100;
break;
case BMCR_SPEED10:
speed = SPEED_10;
break;
default:
speed = SPEED_UNKNOWN
}
jm2c,
wh
btw: an_enabled ? why not !enabled, mich more easy to read
You misinterpret "an_enabled". It's not "negated enabled". It's not
even "disabled". It's short for "autonegotiation enabled". It's
positive logic too.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up
From: Sergei Shtylyov <hidden> Date: 2020-05-02 12:21:28
Hello!
On 01.05.2020 16:43, Colin King wrote:
quoted hunk
From: Colin Ian King <redacted>
The current logic for speed checking will never set the speed to 10 MBPS
because bmcr & BMCR_SPEED10 is always 0 since BMCR_SPEED10 is 0. Also
the erroneous setting where BMCR_SPEED1000 and BMCR_SPEED100 are both
set causes the speed to be 1000 MBS. Fix this by masking bps and checking
for just the expected settings of BMCR_SPEED1000, BMCR_SPEED100 and
BMCR_SPEED10 and defaulting to the unknown speed otherwise.
Addresses-Coverity: ("Logically dead code")
Fixes: ffe10e679cec ("net: dsa: sja1105: Add support for the SGMII port")
Signed-off-by: Colin Ian King <redacted>
---
drivers/net/dsa/sja1105/sja1105_main.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
@@ -1684,14 +1685,16 @@ int sja1105_static_config_reload(struct sja1105_private *priv, sja1105_sgmii_pcs_config(priv, an_enabled, false); if (!an_enabled) {- int speed = SPEED_UNKNOWN;+ int speed;
Why not the following?
int mask = bmcr & (BMCR_SPEED1000 | BMCR_SPEED100 |
BMCR_SPEED10);
- if (bmcr & BMCR_SPEED1000)
+ if ((bmcr & mask) == BMCR_SPEED1000)
speed = SPEED_1000;
- else if (bmcr & BMCR_SPEED100)
+ else if ((bmcr & mask) == BMCR_SPEED100)
speed = SPEED_100;
- else if (bmcr & BMCR_SPEED10)
+ else if ((bmcr & mask) == BMCR_SPEED10)
speed = SPEED_10;
+ else
+ speed = SPEED_UNKNOWN;
sja1105_sgmii_pcs_force_speed(priv, speed);
}