All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: linux-can@vger.kernel.org
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Frank Jungclaus" <frank.jungclaus@esd.eu>,
	"Stefan Mätje" <Stefan.Maetje@esd.eu>,
	"Vincent Mailhol" <mailhol.vincent@wanadoo.fr>,
	"Jimmy Assarsson" <extja@kvaser.com>
Subject: [PATCH v2 07/12] can: kvaser_usb_hydra: do not report txerr and rxerr during bus-off
Date: Tue, 19 Jul 2022 23:35:45 +0900	[thread overview]
Message-ID: <20220719143550.3681-8-mailhol.vincent@wanadoo.fr> (raw)
In-Reply-To: <20220719143550.3681-1-mailhol.vincent@wanadoo.fr>

During bus off, the error count is greater than 255 and can not fit in
a u8.

Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family")
CC: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index a26823c5b62a..af27f0f9aca2 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -917,8 +917,10 @@ static void kvaser_usb_hydra_update_state(struct kvaser_usb_net_priv *priv,
 	    new_state < CAN_STATE_BUS_OFF)
 		priv->can.can_stats.restarts++;
 
-	cf->data[6] = bec->txerr;
-	cf->data[7] = bec->rxerr;
+	if (new_state != CAN_STATE_BUS_OFF) {
+		cf->data[6] = bec->txerr;
+		cf->data[7] = bec->rxerr;
+	}
 
 	netif_rx(skb);
 }
@@ -1069,8 +1071,10 @@ kvaser_usb_hydra_error_frame(struct kvaser_usb_net_priv *priv,
 	shhwtstamps->hwtstamp = hwtstamp;
 
 	cf->can_id |= CAN_ERR_BUSERROR;
-	cf->data[6] = bec.txerr;
-	cf->data[7] = bec.rxerr;
+	if (new_state != CAN_STATE_BUS_OFF) {
+		cf->data[6] = bec.txerr;
+		cf->data[7] = bec.rxerr;
+	}
 
 	netif_rx(skb);
 
-- 
2.35.1


  parent reply	other threads:[~2022-07-19 14:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 15:31 [PATCH v1 00/12] can: error: set of fixes and improvement on txerr and rxerr reporting Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 01/12] can: pch_can: do not report txerr and rxerr during bus-off Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 02/12] can: rcar_can: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 03/12] can: sja1000: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 04/12] can: slcan: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 05/12] can: hi311x: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 06/12] can: sun4i_can: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 07/12] can: kvaser_usb_hydra: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 08/12] can: kvaser_usb_leaf: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 09/12] can: usb_8dev: " Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 10/12] can: error: specify the values of data[5..7] of CAN error frames Vincent Mailhol
2022-07-19 10:44   ` Stefan Mätje
2022-07-19 14:14     ` Vincent MAILHOL
2022-07-12 15:31 ` [PATCH v1 11/12] can: add CAN_ERR_CNT flag to notify availability of error counter Vincent Mailhol
2022-07-12 15:31 ` [PATCH v1 12/12] can: error: add definitions for the different CAN error thresholds Vincent Mailhol
2022-07-19 14:35 ` [PATCH v2 00/12] can: error: set of fixes and improvement on txerr and rxerr reporting Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 01/12] can: pch_can: do not report txerr and rxerr during bus-off Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 02/12] can: rcar_can: " Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 03/12] can: sja1000: " Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 04/12] can: slcan: " Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 05/12] can: hi311x: " Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 06/12] can: sun4i_can: " Vincent Mailhol
2022-07-19 14:35   ` Vincent Mailhol [this message]
2022-07-19 14:35   ` [PATCH v2 08/12] can: kvaser_usb_leaf: " Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 09/12] can: usb_8dev: " Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 10/12] can: error: specify the values of data[5..7] of CAN error frames Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 11/12] can: add CAN_ERR_CNT flag to notify availability of error counter Vincent Mailhol
2022-07-19 14:35   ` [PATCH v2 12/12] can: error: add definitions for the different CAN error thresholds Vincent Mailhol
2022-07-20  7:17   ` [PATCH v2 00/12] can: error: set of fixes and improvement on txerr and rxerr reporting Marc Kleine-Budde
2022-07-20  7:24     ` Vincent MAILHOL

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220719143550.3681-8-mailhol.vincent@wanadoo.fr \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=Stefan.Maetje@esd.eu \
    --cc=extja@kvaser.com \
    --cc=frank.jungclaus@esd.eu \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.