Skip to content

Commit

Permalink
can: esd_usb: Move mislocated storage of SJA1000_ECC_SEG bits in case…
Browse files Browse the repository at this point in the history
… of a bus error

[ Upstream commit 118469f ]

Move the supply for cf->data[3] (bit stream position of CAN error), in
case of a bus- or protocol-error, outside of the "switch (ecc &
SJA1000_ECC_MASK){}"-statement, because this bit stream position is
independent of the error type.

Fixes: 96d8e90 ("can: Add driver for esd CAN-USB/2 device")
Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
Link: https://lore.kernel.org/all/20230216190450.3901254-2-frank.jungclaus@esd.eu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Frank Jungclaus authored and gregkh committed Mar 10, 2023
1 parent 026ba2f commit 08d2f67
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/can/usb/esd_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,16 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
cf->data[2] |= CAN_ERR_PROT_STUFF;
break;
default:
cf->data[3] = ecc & SJA1000_ECC_SEG;
break;
}

/* Error occurred during transmission? */
if (!(ecc & SJA1000_ECC_DIR))
cf->data[2] |= CAN_ERR_PROT_TX;

/* Bit stream position in CAN frame as the error was detected */
cf->data[3] = ecc & SJA1000_ECC_SEG;

if (priv->can.state == CAN_STATE_ERROR_WARNING ||
priv->can.state == CAN_STATE_ERROR_PASSIVE) {
cf->data[1] = (txerr > rxerr) ?
Expand Down

0 comments on commit 08d2f67

Please sign in to comment.