Skip to content

Commit 8ce261d

Browse files
Sebastian Andrzej Siewiormarckleinebudde
authored andcommitted
can: flexcan: handle state passive -> warning transition
Once the CAN-bus is open and a packet is sent, the controller switches into the PASSIVE state. Once the BUS is closed again it goes the back err-warning. The TX error counter goes 0 -> 0x80 -> 0x7f. This patch makes sure that the user learns about this state chang (CAN_STATE_ERROR_WARNING => CAN_STATE_ERROR_PASSIVE) Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Matthias Klein <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent bc03a54 commit 8ce261d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/net/can/flexcan.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,13 @@ static void do_state(struct net_device *dev,
549549

550550
/* process state changes depending on the new state */
551551
switch (new_state) {
552+
case CAN_STATE_ERROR_WARNING:
553+
netdev_dbg(dev, "Error Warning\n");
554+
cf->can_id |= CAN_ERR_CRTL;
555+
cf->data[1] = (bec.txerr > bec.rxerr) ?
556+
CAN_ERR_CRTL_TX_WARNING :
557+
CAN_ERR_CRTL_RX_WARNING;
558+
break;
552559
case CAN_STATE_ERROR_ACTIVE:
553560
netdev_dbg(dev, "Error Active\n");
554561
cf->can_id |= CAN_ERR_PROT;

0 commit comments

Comments
 (0)