Skip to content

Commit 0d515ff

Browse files
passgatgregkh
authored andcommitted
can: sun4i_can: sun4i_can_err(): fix {rx,tx}_errors statistics
[ Upstream commit 595a819 ] The sun4i_can_err() function only incremented the receive error counter and never the transmit error counter, even if the STA_ERR_DIR flag reported that an error had occurred during transmission. Increment the receive/transmit error counter based on the value of the STA_ERR_DIR flag. Fixes: 0738eff ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Link: https://patch.msgid.link/20241122221650.633981-11-dario.binacchi@amarulasolutions.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bc18651 commit 0d515ff

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/net/can/sun4i_can.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,9 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
579579
/* bus error interrupt */
580580
netdev_dbg(dev, "bus error interrupt\n");
581581
priv->can.can_stats.bus_error++;
582-
stats->rx_errors++;
582+
ecc = readl(priv->base + SUN4I_REG_STA_ADDR);
583583

584584
if (likely(skb)) {
585-
ecc = readl(priv->base + SUN4I_REG_STA_ADDR);
586-
587585
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
588586

589587
switch (ecc & SUN4I_STA_MASK_ERR) {
@@ -601,9 +599,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
601599
>> 16;
602600
break;
603601
}
604-
/* error occurred during transmission? */
605-
if ((ecc & SUN4I_STA_ERR_DIR) == 0)
602+
}
603+
604+
/* error occurred during transmission? */
605+
if ((ecc & SUN4I_STA_ERR_DIR) == 0) {
606+
if (likely(skb))
606607
cf->data[2] |= CAN_ERR_PROT_TX;
608+
stats->tx_errors++;
609+
} else {
610+
stats->rx_errors++;
607611
}
608612
}
609613
if (isrc & SUN4I_INT_ERR_PASSIVE) {

0 commit comments

Comments
 (0)