All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Schneider-Pargmann <msp@baylibre.com>
To: Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Wolfgang Grandegger <wg@grandegger.com>
Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Markus Schneider-Pargmann <msp@baylibre.com>
Subject: [PATCH v2 09/11] can: tcan4x5x: Fix use of register error status mask
Date: Tue,  6 Dec 2022 12:57:26 +0100	[thread overview]
Message-ID: <20221206115728.1056014-10-msp@baylibre.com> (raw)
In-Reply-To: <20221206115728.1056014-1-msp@baylibre.com>

TCAN4X5X_ERROR_STATUS is not a status register that needs clearing
during interrupt handling. Instead this is a masking register that masks
error interrupts. Writing TCAN4X5X_CLEAR_ALL_INT to this register
effectively masks everything.

Rename the register and mask all error interrupts only once by writing
to the register in tcan4x5x_init.

Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---

Notes:
    v2:
     - Add fixes tag

 drivers/net/can/m_can/tcan4x5x-core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index 1fec394b3517..efa2381bf85b 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -10,7 +10,7 @@
 #define TCAN4X5X_DEV_ID1 0x04
 #define TCAN4X5X_REV 0x08
 #define TCAN4X5X_STATUS 0x0C
-#define TCAN4X5X_ERROR_STATUS 0x10
+#define TCAN4X5X_ERROR_STATUS_MASK 0x10
 #define TCAN4X5X_CONTROL 0x14
 
 #define TCAN4X5X_CONFIG 0x800
@@ -204,12 +204,7 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
-	ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS,
-				      TCAN4X5X_CLEAR_ALL_INT);
-	if (ret)
-		return ret;
-
-	return tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_ERROR_STATUS,
+	return tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS,
 				       TCAN4X5X_CLEAR_ALL_INT);
 }
 
@@ -229,6 +224,11 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
+	ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_ERROR_STATUS_MASK,
+				      TCAN4X5X_CLEAR_ALL_INT);
+	if (ret)
+		return ret;
+
 	/* Zero out the MCAN buffers */
 	ret = m_can_init_ram(cdev);
 	if (ret)
-- 
2.38.1


  parent reply	other threads:[~2022-12-06 11:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 11:57 [PATCH v2 00/11] can: m_can: Optimizations for tcan and peripheral chips Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 01/11] can: m_can: Eliminate double read of TXFQS in tx_handler Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 02/11] can: m_can: Avoid reading irqstatus twice Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 03/11] can: m_can: Read register PSR only on error Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 04/11] can: m_can: Count TXE FIFO getidx in the driver Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 05/11] can: m_can: Count read getindex " Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 06/11] can: m_can: Batch acknowledge transmit events Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 07/11] can: m_can: Batch acknowledge rx fifo Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 08/11] can: tcan4x5x: Remove invalid write in clear_interrupts Markus Schneider-Pargmann
2022-12-06 11:57 ` Markus Schneider-Pargmann [this message]
2022-12-06 11:57 ` [PATCH v2 10/11] can: tcan4x5x: Fix register range of first two blocks Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 11/11] can: tcan4x5x: Specify separate read/write ranges Markus Schneider-Pargmann
2022-12-06 16:20   ` Marc Kleine-Budde
2022-12-12 10:54     ` Marc Kleine-Budde
2022-12-13 17:10       ` Markus Schneider-Pargmann
2022-12-13 19:10         ` Markus Schneider-Pargmann
2022-12-13 19:13           ` Marc Kleine-Budde

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=20221206115728.1056014-10-msp@baylibre.com \
    --to=msp@baylibre.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=rcsekar@samsung.com \
    --cc=wg@grandegger.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.