提交 e638642b 编写于 作者: A Ahmed S. Darwish 提交者: Marc Kleine-Budde

can: kvaser_usb: Fix state handling upon BUS_ERROR events

While being in an ERROR_WARNING state, and receiving further
bus error events with error counters still in the ERROR_WARNING
range of 97-127 inclusive, the state handling code erroneously
reverts back to ERROR_ACTIVE.

Per the CAN standard, only revert to ERROR_ACTIVE when the
error counters are less than 96.

Moreover, in certain Kvaser models, the BUS_ERROR flag is
always set along with undefined bits in the M16C status
register. Thus use bitwise operators instead of full equality
for checking that register against bus errors.
Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
上级 14c10c2a
...@@ -698,9 +698,7 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev, ...@@ -698,9 +698,7 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
} }
new_state = CAN_STATE_ERROR_PASSIVE; new_state = CAN_STATE_ERROR_PASSIVE;
} } else if (status & M16C_STATE_BUS_ERROR) {
if (status == M16C_STATE_BUS_ERROR) {
if ((priv->can.state < CAN_STATE_ERROR_WARNING) && if ((priv->can.state < CAN_STATE_ERROR_WARNING) &&
((txerr >= 96) || (rxerr >= 96))) { ((txerr >= 96) || (rxerr >= 96))) {
cf->can_id |= CAN_ERR_CRTL; cf->can_id |= CAN_ERR_CRTL;
...@@ -710,7 +708,8 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev, ...@@ -710,7 +708,8 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
priv->can.can_stats.error_warning++; priv->can.can_stats.error_warning++;
new_state = CAN_STATE_ERROR_WARNING; new_state = CAN_STATE_ERROR_WARNING;
} else if (priv->can.state > CAN_STATE_ERROR_ACTIVE) { } else if ((priv->can.state > CAN_STATE_ERROR_ACTIVE) &&
((txerr < 96) && (rxerr < 96))) {
cf->can_id |= CAN_ERR_PROT; cf->can_id |= CAN_ERR_PROT;
cf->data[2] = CAN_ERR_PROT_ACTIVE; cf->data[2] = CAN_ERR_PROT_ACTIVE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册