Skip to content

Commit 1e50cf6

Browse files
passgatsmb49
authored andcommitted
can: f81604: f81604_handle_can_bus_errors(): fix {rx,tx}_errors statistics
BugLink: https://bugs.launchpad.net/bugs/2102118 [ Upstream commit d7b9165 ] The f81604_handle_can_bus_errors() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 88da174 ("can: usb: f81604: add Fintek F81604 support") Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Link: https://patch.msgid.link/20241122221650.633981-13-dario.binacchi@amarulasolutions.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent f48ac62 commit 1e50cf6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/net/can/usb/f81604.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ static void f81604_handle_can_bus_errors(struct f81604_port_priv *priv,
526526
netdev_dbg(netdev, "bus error interrupt\n");
527527

528528
priv->can.can_stats.bus_error++;
529-
stats->rx_errors++;
530529

531530
if (skb) {
532531
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
@@ -548,10 +547,15 @@ static void f81604_handle_can_bus_errors(struct f81604_port_priv *priv,
548547

549548
/* set error location */
550549
cf->data[3] = data->ecc & F81604_SJA1000_ECC_SEG;
550+
}
551551

552-
/* Error occurred during transmission? */
553-
if ((data->ecc & F81604_SJA1000_ECC_DIR) == 0)
552+
/* Error occurred during transmission? */
553+
if ((data->ecc & F81604_SJA1000_ECC_DIR) == 0) {
554+
stats->tx_errors++;
555+
if (skb)
554556
cf->data[2] |= CAN_ERR_PROT_TX;
557+
} else {
558+
stats->rx_errors++;
555559
}
556560

557561
set_bit(F81604_CLEAR_ECC, &priv->clear_flags);

0 commit comments

Comments
 (0)