netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: socketcan-core@lists.berlios.de
Cc: netdev@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 5/7] can: mcp251x: write intf only when needed
Date: Fri, 15 Oct 2010 12:49:20 +0200	[thread overview]
Message-ID: <1287139762-23356-6-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1287139762-23356-1-git-send-email-mkl@pengutronix.de>

This patch introduces a variable "clear_intf" that hold the bits that
should be cleared. Only read-modify-write register if "clear_intf"
is set.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/mcp251x.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 7e2f951..f5e2edd 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -125,6 +125,8 @@
 #  define CANINTF_TX0IF 0x04
 #  define CANINTF_RX1IF 0x02
 #  define CANINTF_RX0IF 0x01
+#  define CANINTF_ERR_TX \
+	(CANINTF_ERRIF | CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF)
 #define EFLG	      0x2d
 #  define EFLG_EWARN	0x01
 #  define EFLG_RXWAR	0x02
@@ -769,10 +771,12 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
 	while (!priv->force_quit) {
 		enum can_state new_state;
 		u8 intf, eflag;
+		u8 clear_intf = 0;
 		int can_id = 0, data1 = 0;
 
 		mcp251x_read_2regs(spi, CANINTF, &intf, &eflag);
 
+		/* receive buffer 0 */
 		if (intf & CANINTF_RX0IF) {
 			mcp251x_hw_rx(spi, 0);
 			/* Free one buffer ASAP */
@@ -780,10 +784,17 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
 					   0x00);
 		}
 
-		if (intf & CANINTF_RX1IF)
+		/* receive buffer 1 */
+		if (intf & CANINTF_RX1IF) {
 			mcp251x_hw_rx(spi, 1);
+			clear_intf |= CANINTF_RX1IF;
+		}
 
-		mcp251x_write_bits(spi, CANINTF, intf, 0x00);
+		/* any error or tx interrupt we need to clear? */
+		if (intf & CANINTF_ERR_TX)
+			clear_intf |= intf & CANINTF_ERR_TX;
+		if (clear_intf)
+			mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00);
 
 		if (eflag)
 			mcp251x_write_bits(spi, EFLG, eflag, 0x00);
-- 
1.7.0.4


  parent reply	other threads:[~2010-10-15 10:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15 10:49 [PATCH V2 0/7] can: mcp251x: fix and optimize driver Marc Kleine-Budde
     [not found] ` <1287139762-23356-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-15 10:49   ` [PATCH 1/7] can: mcp251x: fix NOHZ local_softirq_pending 08 warning Marc Kleine-Budde
2010-10-15 10:49   ` [PATCH 2/7] can: mcp251x: increase rx_errors on overflow, not only rx_over_errors Marc Kleine-Budde
2010-10-15 10:49   ` [PATCH 3/7] can: mcp251x: allow to read two registers in one spi transfer Marc Kleine-Budde
2010-10-15 10:49   ` [PATCH 4/7] can: mcp251x: read-modify-write eflag only when needed Marc Kleine-Budde
2010-10-15 10:49   ` [PATCH 6/7] can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515 Marc Kleine-Budde
2010-10-17 14:29   ` [PATCH V2 0/7] can: mcp251x: fix and optimize driver Wolfgang Grandegger
     [not found]     ` <4CBB0851.9060601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-10-18  9:19       ` Marc Kleine-Budde
2010-10-15 10:49 ` Marc Kleine-Budde [this message]
2010-10-15 10:49 ` [PATCH 7/7] can: mcp251x: optimize 2515, rx int gets cleared automatically 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=1287139762-23356-6-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan-core@lists.berlios.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).