All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-can@vger.kernel.org,
	kernel@pengutronix.de,
	Jeroen Hofstee <jhofstee@victronenergy.com>,
	Stephane Grosjean <s.grosjean@peak-system.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 08/33] can: peak_usb: report bus recovery as well
Date: Tue,  5 Nov 2019 17:31:50 +0100	[thread overview]
Message-ID: <20191105163215.30194-9-mkl@pengutronix.de> (raw)
In-Reply-To: <20191105163215.30194-1-mkl@pengutronix.de>

From: Jeroen Hofstee <jhofstee@victronenergy.com>

While the state changes are reported when the error counters increase
and decrease, there is no event when the bus recovers and the error
counters decrease again. So add those as well.

Change the state going downward to be ERROR_PASSIVE -> ERROR_WARNING ->
ERROR_ACTIVE instead of directly to ERROR_ACTIVE again.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Cc: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 5a66c9f53aae..d2539c95adb6 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -436,8 +436,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 		}
 		if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) {
 			/* no error (back to active state) */
-			mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE;
-			return 0;
+			new_state = CAN_STATE_ERROR_ACTIVE;
+			break;
 		}
 		break;
 
@@ -460,9 +460,9 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 		}
 
 		if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) {
-			/* no error (back to active state) */
-			mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE;
-			return 0;
+			/* no error (back to warning state) */
+			new_state = CAN_STATE_ERROR_WARNING;
+			break;
 		}
 		break;
 
@@ -501,6 +501,11 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 		mc->pdev->dev.can.can_stats.error_warning++;
 		break;
 
+	case CAN_STATE_ERROR_ACTIVE:
+		cf->can_id |= CAN_ERR_CRTL;
+		cf->data[1] = CAN_ERR_CRTL_ACTIVE;
+		break;
+
 	default:
 		/* CAN_STATE_MAX (trick to handle other errors) */
 		cf->can_id |= CAN_ERR_CRTL;
-- 
2.24.0.rc1

  parent reply	other threads:[~2019-11-05 16:31 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 16:31 pull-request: can 2019-11-05 Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 01/33] can: dev: add missing of_node_put() after calling of_get_child_by_name() Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 02/33] can: gs_usb: gs_can_open(): prevent memory leak Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 03/33] can: mcba_usb: fix use-after-free on disconnect Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 04/33] can: usb_8dev: " Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 05/33] can: flexcan: disable completely the ECC mechanism Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 06/33] can: peak_usb: fix a potential out-of-sync while decoding packets Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 07/33] can: peak_usb: fix slab info leak Marc Kleine-Budde
2019-11-05 16:31 ` Marc Kleine-Budde [this message]
2019-11-05 16:31 ` [PATCH 09/33] can: c_can: c_can_poll(): only read status register after status IRQ Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 10/33] can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 11/33] can: c_can: C_CAN: add bus recovery events Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 12/33] can: xilinx_can: Fix flags field initialization for axi can Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 13/33] can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 14/33] can: rx-offload: can_rx_offload_queue_tail(): " Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 15/33] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 16/33] can: rx-offload: can_rx_offload_offload_one(): increment rx_fifo_errors on queue overflow or OOM Marc Kleine-Budde
2019-11-05 16:31 ` [PATCH 17/33] can: rx-offload: can_rx_offload_offload_one(): use ERR_PTR() to propagate error value in case of errors Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 18/33] can: rx-offload: can_rx_offload_irq_offload_timestamp(): continue on error Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 19/33] can: rx-offload: can_rx_offload_irq_offload_fifo(): " Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 20/33] can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 21/33] can: ti_hecc: ti_hecc_error(): " Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 22/33] can: ti_hecc: ti_hecc_stop(): stop the CPK on down Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 23/33] can: ti_hecc: keep MIM and MD set Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 24/33] can: ti_hecc: release the mailbox a bit earlier Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 25/33] can: ti_hecc: add fifo overflow error reporting Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 26/33] can: ti_hecc: properly report state changes Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 27/33] can: ti_hecc: add missing " Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 28/33] can: j1939: fix resource leak of skb on error return paths Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 29/33] can: j1939: fix memory leak if filters was set Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 30/33] can: j1939: transport: j1939_session_fresh_new(): make sure EOMA is send with the total message size set Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 31/33] can: j1939: transport: j1939_xtp_rx_eoma_one(): Add sanity check for correct total message size Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 32/33] can: mcp251x: mcp251x_restart_work_handler(): Fix potential force_quit race condition Marc Kleine-Budde
2019-11-05 16:32 ` [PATCH 33/33] can: don't use deprecated license identifiers Marc Kleine-Budde
2019-11-05 21:30 ` pull-request: can 2019-11-05 David Miller
2019-11-05 21:36   ` Marc Kleine-Budde
2019-11-07  8:45 ` request: merge net/master into net-next/master Marc Kleine-Budde
2019-11-09 20:28   ` request: merge net/master into net-next/master,request: " David Miller

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=20191105163215.30194-9-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=jhofstee@victronenergy.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=s.grosjean@peak-system.com \
    /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.