summaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorAhmed S. Darwish <ahmed.darwish@valeo.com>2015-02-02 15:15:55 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2015-02-04 08:07:03 -0500
commita9ca6e13d66042b3ac18d1352b88b7cd0da8fc21 (patch)
tree9469dc573b7cd674b591fc244fc8f5b130642dc4 /drivers/net/can
parent8a00785edd166361e08c6cf710bf3acdd6038005 (diff)
can: kvaser_usb: Ignore spurious error events after a busoff
Sending data in high speed then introducing a busoff results in spurious BUS_ERROR events from the USBCan-II firmware directly _after_ the triggered BUS_OFF event. In the current CAN state handling code, this will lead to an invalid can state of ACTIVE, ERROR, or PASSIVE even though the CAN controller has been already shut down due to the busoff. Guard the state handling code from such invalid events. Signed-off-by: Ahmed S. Darwish <ahmed.darwish@valeo.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/usb/kvaser_usb.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 17d28d7dd412..2928f7003041 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -11,7 +11,7 @@
11 * Copyright (C) 2002-2006 KVASER AB, Sweden. All rights reserved. 11 * Copyright (C) 2002-2006 KVASER AB, Sweden. All rights reserved.
12 * Copyright (C) 2010 Matthias Fuchs <matthias.fuchs@esd.eu>, esd gmbh 12 * Copyright (C) 2010 Matthias Fuchs <matthias.fuchs@esd.eu>, esd gmbh
13 * Copyright (C) 2012 Olivier Sobrie <olivier@sobrie.be> 13 * Copyright (C) 2012 Olivier Sobrie <olivier@sobrie.be>
14 * Copyright (C) 2015 Valeo A.S. 14 * Copyright (C) 2015 Valeo S.A.
15 */ 15 */
16 16
17#include <linux/completion.h> 17#include <linux/completion.h>
@@ -824,14 +824,15 @@ static void kvaser_usb_rx_error_update_can_state(struct kvaser_usb_net_priv *pri
824 else if (es->status & M16C_STATE_BUS_PASSIVE) 824 else if (es->status & M16C_STATE_BUS_PASSIVE)
825 new_state = CAN_STATE_ERROR_PASSIVE; 825 new_state = CAN_STATE_ERROR_PASSIVE;
826 else if (es->status & M16C_STATE_BUS_ERROR) { 826 else if (es->status & M16C_STATE_BUS_ERROR) {
827 if ((es->txerr >= 256) || (es->rxerr >= 256)) 827 /* Guard against spurious error events after a busoff */
828 new_state = CAN_STATE_BUS_OFF; 828 if (cur_state < CAN_STATE_BUS_OFF) {
829 else if ((es->txerr >= 128) || (es->rxerr >= 128)) 829 if ((es->txerr >= 128) || (es->rxerr >= 128))
830 new_state = CAN_STATE_ERROR_PASSIVE; 830 new_state = CAN_STATE_ERROR_PASSIVE;
831 else if ((es->txerr >= 96) || (es->rxerr >= 96)) 831 else if ((es->txerr >= 96) || (es->rxerr >= 96))
832 new_state = CAN_STATE_ERROR_WARNING; 832 new_state = CAN_STATE_ERROR_WARNING;
833 else if (cur_state > CAN_STATE_ERROR_ACTIVE) 833 else if (cur_state > CAN_STATE_ERROR_ACTIVE)
834 new_state = CAN_STATE_ERROR_ACTIVE; 834 new_state = CAN_STATE_ERROR_ACTIVE;
835 }
835 } 836 }
836 837
837 if (!es->status) 838 if (!es->status)