]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
can: sja1000: do not report txerr and rxerr during bus-off
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Tue, 19 Jul 2022 14:35:41 +0000 (23:35 +0900)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 20 Jul 2022 07:26:49 +0000 (09:26 +0200)
During bus off, the error count is greater than 255 and can not fit in
a u8.

Fixes: 215db1856e83 ("can: sja1000: Consolidate and unify state change handling")
Link: https://lore.kernel.org/all/20220719143550.3681-4-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/sja1000/sja1000.c

index d9da471f1bb91aaf5a5a34494d90ed28f734924e..74bff5092b4724b8b9abb9416b630dd24ab9c5fd 100644 (file)
@@ -404,9 +404,6 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
        txerr = priv->read_reg(priv, SJA1000_TXERR);
        rxerr = priv->read_reg(priv, SJA1000_RXERR);
 
-       cf->data[6] = txerr;
-       cf->data[7] = rxerr;
-
        if (isrc & IRQ_DOI) {
                /* data overrun interrupt */
                netdev_dbg(dev, "data overrun interrupt\n");
@@ -428,6 +425,10 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
                else
                        state = CAN_STATE_ERROR_ACTIVE;
        }
+       if (state != CAN_STATE_BUS_OFF) {
+               cf->data[6] = txerr;
+               cf->data[7] = rxerr;
+       }
        if (isrc & IRQ_BEI) {
                /* bus error interrupt */
                priv->can.can_stats.bus_error++;