pch_can: fix error passive level test
Subsystems (3)
PATCH 1/1 pch_can: fix error passive level test
The test (((errc & PCH_REC) >> 8) > 127) would always be false because the receive error counter ((errc & PCH_REC) >> 8) is at most 127, where PCH_REC is defined as 0x7f00. To test whether the receive error counter has reached the error passive level, the RP bit (15) should be used.
--- drivers/net/can/pch_can.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/can/pch_can.c +2 -1
@@ -66,6 +66,7 @@#define PCH_IF_CREQ_BUSY BIT(15)#define PCH_STATUS_INT 0x8000 +#define PCH_RP 0x00008000#define PCH_REC 0x00007f00#define PCH_TEC 0x000000ff
@@ -527,7 +528,7 @@ static void pch_can_error(struct net_device *ndev, u32 status) priv->can.can_stats.error_passive++; state =CAN_STATE_ERROR_PASSIVE ; cf->can_id |=CAN_ERR_CRTL ; -if (((errc &PCH_REC ) >>8 ) >127 ) +if (errc &PCH_RP ) cf->data[1 ] |=CAN_ERR_CRTL_RX_PASSIVE ;if ((errc &PCH_TEC ) >127 ) cf->data[1 ] |=CAN_ERR_CRTL_TX_PASSIVE ;
Signature · 1 line
1.7.5.4
Quoted 6 lines · Xi Wang
The test (((errc &
PCH_REC) >> 8) > 127) would always be false because the receive error counter ((errc &PCH_REC) >> 8) is at most 127, wherePCH_RECis defined as0x7f00. To test whether the receive error counter has reached the error passive level, the RP bit (15) should be used.Signed-off-by Xi Wang <[email protected]>
The C_CAN driver, which supports the same CAN controller, does handle the error passive state correctly. This reminds me to get rid of pch_can in favor of C_CAN sooner than later.
Thanks,
Wolfgang.
Marc Kleine-Budde
maintainerQuoted 9 lines · Wolfgang Grandegger
Quoted 6 lines · Xi Wang
The test (((errc &
PCH_REC) >> 8) > 127) would always be false because the receive error counter ((errc &PCH_REC) >> 8) is at most 127, wherePCH_RECis defined as0x7f00. To test whether the receive error counter has reached the error passive level, the RP bit (15) should be used.Signed-off-by Xi Wang <[email protected]>
Is this patch a candidate for stable?
Quoted 3 lines
The
C_CANdriver, which supports the same CAN controller, does handle the error passive state correctly. This reminds me to get rid ofpch_canin favor ofC_CANsooner than later.
+1
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Quoted 7 lines · Marc Kleine-Budde
Quoted 6 lines · Wolfgang Grandegger
Quoted 5 lines · Xi Wang
The test (((errc &
PCH_REC) >> 8) > 127) would always be false because the receive error counter ((errc &PCH_REC) >> 8) is at most 127, wherePCH_RECis defined as0x7f00. To test whether the receive error counter has reached the error passive level, the RP bit (15) should be used.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Xi Wang <[email protected]>Is this patch a candidate for stable?
You mean for the "net" branch? Yes, I think so.
Wolfgang.
Marc Kleine-Budde
maintainerQuoted 8 lines · Wolfgang Grandegger
Quoted 7 lines · Marc Kleine-Budde
Quoted 6 lines · Wolfgang Grandegger
Quoted 5 lines · Xi Wang
The test (((errc &
PCH_REC) >> 8) > 127) would always be false because the receive error counter ((errc &PCH_REC) >> 8) is at most 127, wherePCH_RECis defined as0x7f00. To test whether the receive error counter has reached the error passive level, the RP bit (15) should be used.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Xi Wang <[email protected]>Is this patch a candidate for stable?
You mean for the "net" branch? Yes, I think so.
Even for all trees which contain this driver (in a working version), which is v2.6.38 and newer.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Quoted 11 lines · Marc Kleine-Budde
Quoted 10 lines · Wolfgang Grandegger
Quoted 9 lines · Marc Kleine-Budde
Quoted 8 lines · Wolfgang Grandegger
Quoted 6 lines · Xi Wang
The test (((errc &
PCH_REC) >> 8) > 127) would always be false because the receive error counter ((errc &PCH_REC) >> 8) is at most 127, wherePCH_RECis defined as0x7f00. To test whether the receive error counter has reached the error passive level, the RP bit (15) should be used.Signed-off-by Xi Wang <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Is this patch a candidate for stable?
You mean for the "net" branch? Yes, I think so.
Even for all trees which contain this driver (in a working version), which is v2.6.38 and newer.
OK, Well, it's not a serious fix, at least.
Wolfgang.
Quoted 6 lines · Wolfgang Grandegger
Quoted 3 lines · Marc Kleine-Budde
Even for all trees which contain this driver (in a working version), which is v2.6.38 and newer.
OK, Well, it's not a serious fix, at least.
Should I resend the patch and cc to stable? Thanks.
- xi