Skip to contentSkip to conversation

pch_can: fix error passive level test

PATCH In review Xi Wang 3 participants 7 messages Dec 12, 2011 – Jan 7, 2012

Subsystems (3)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

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
index d11fbb2..6edc25e 100644
@@ -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
Acked-by on v1 1/1
#1 lore raw
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, 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.

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.

#2 lore raw
Quoted 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, 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.

Is this patch a candidate for stable?

Quoted 3 lines

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.

+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   |
#3 lore raw
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, 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.

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.

Wolfgang.

#4 lore raw
Quoted 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, 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.

Quoted 7 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.

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   |
#5 lore raw
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, 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.

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.

author
#6 lore raw
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