@@ -635,10 +635,12 @@ static void kvaser_usb_rx_error_update_can_state(struct kvaser_usb_net_priv *pri
new_state = CAN_STATE_BUS_OFF;
else if (es->status & M16C_STATE_BUS_PASSIVE)
new_state = CAN_STATE_ERROR_PASSIVE;
-
- if (es->status == M16C_STATE_BUS_ERROR) {
- if ((cur_state < CAN_STATE_ERROR_WARNING) &&
- ((es->txerr >= 96) || (es->rxerr >= 96)))
+ else if (es->status & M16C_STATE_BUS_ERROR) {
+ if ((es->txerr >= 256) || (es->rxerr >= 256))
+ new_state = CAN_STATE_BUS_OFF;
+ else if ((es->txerr >= 128) || (es->rxerr >= 128))
+ new_state = CAN_STATE_ERROR_PASSIVE;
+ else if ((es->txerr >= 96) || (es->rxerr >= 96))
new_state = CAN_STATE_ERROR_WARNING;
else if (cur_state > CAN_STATE_ERROR_ACTIVE)
new_state = CAN_STATE_ERROR_ACTIVE;
@@ -748,15 +750,11 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
if (!priv->can.restart_ms)
kvaser_usb_simple_msg_async(priv, CMD_STOP_CHIP);
netif_carrier_off(priv->netdev);
- }
-
- if (es.status == M16C_STATE_BUS_ERROR) {
- if ((old_state >= CAN_STATE_ERROR_WARNING) ||
- (es.txerr < 96 && es.rxerr < 96)) {
- if (old_state > CAN_STATE_ERROR_ACTIVE) {
- cf->can_id |= CAN_ERR_PROT;
- cf->data[2] = CAN_ERR_PROT_ACTIVE;
- }
+ } else if (es.status & M16C_STATE_BUS_ERROR) {
+ if ((es.txerr < 96 && es.rxerr < 96) &&
+ (old_state > CAN_STATE_ERROR_ACTIVE)) {
+ cf->can_id |= CAN_ERR_PROT;
+ cf->data[2] = CAN_ERR_PROT_ACTIVE;
}
}