linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Federico Vaga <federico.vaga@cern.ch>
To: <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Peter Korsgaard" <jacmet@sunsite.dk>
Cc: <federico.vaga@cern.ch>
Subject: [PATCH 2/3] i2c:ocores: do not handle IRQ if IF is not set
Date: Mon, 25 Jun 2018 18:13:02 +0200	[thread overview]
Message-ID: <20180625161303.7991-3-federico.vaga@cern.ch> (raw)
In-Reply-To: <20180625161303.7991-1-federico.vaga@cern.ch>

If the Interrupt Flag (IF) is not set, we should not handle the IRQ:
- the line can be shared with other devices
- it can be a spurious interrupt

To avoid reading twice the status register, the ocores_process() function
expects it to be read by the caller.

Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
---
 drivers/i2c/busses/i2c-ocores.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 98c0ef74882b..274d6eb22a2c 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -139,10 +139,9 @@ static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg)
 	return i2c->getreg(i2c, reg);
 }
 
-static void ocores_process(struct ocores_i2c *i2c)
+static void ocores_process(struct ocores_i2c *i2c, u8 stat)
 {
 	struct i2c_msg *msg = i2c->msg;
-	u8 stat = oc_getreg(i2c, OCI2C_STATUS);
 
 	if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) {
 		/* stop has been sent */
@@ -209,9 +208,13 @@ static void ocores_process(struct ocores_i2c *i2c)
 static irqreturn_t ocores_isr(int irq, void *dev_id)
 {
 	struct ocores_i2c *i2c = dev_id;
+	u8 stat = oc_getreg(i2c, OCI2C_STATUS);
 	unsigned long flags;
 	int ret;
 
+	if (!(stat & OCI2C_STAT_IF))
+		return IRQ_NONE;
+
 	/*
 	 * We need to protect i2c against a timeout event (see ocores_xfer())
 	 * If we cannot take this lock, it means that we are already in
@@ -222,7 +225,7 @@ static irqreturn_t ocores_isr(int irq, void *dev_id)
 	if (!ret)
 		return IRQ_HANDLED;
 
-	ocores_process(i2c);
+	ocores_process(i2c, stat);
 
 	spin_unlock_irqrestore(&i2c->xfer_lock, flags);
 
-- 
2.15.0


  parent reply	other threads:[~2018-06-25 16:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 16:13 i2c:ocores: fixes and polling mechanism Federico Vaga
2018-06-25 16:13 ` [PATCH 1/3] i2c:ocores: stop transfer on timeout Federico Vaga
2018-10-21 14:10   ` Peter Korsgaard
2018-10-24 14:51     ` Federico Vaga
2018-10-26 17:46       ` Peter Korsgaard
2018-10-25  7:42     ` Federico Vaga
2018-06-25 16:13 ` Federico Vaga [this message]
2018-10-21 14:12   ` [PATCH 2/3] i2c:ocores: do not handle IRQ if IF is not set Peter Korsgaard
2018-10-29  8:53     ` Wolfram Sang
2018-10-29 14:27       ` Federico Vaga
2018-06-25 16:13 ` [PATCH 3/3] i2c:ocores: add polling interface Federico Vaga
2018-10-21 14:39   ` Peter Korsgaard
2018-10-24  9:51     ` Federico Vaga
2018-10-26 17:45       ` Peter Korsgaard
2018-10-29  8:50         ` Federico Vaga
2018-10-29 13:04           ` Peter Korsgaard
2018-10-29 13:11             ` Federico Vaga
2018-10-25  7:47     ` Federico Vaga
2018-08-11 17:13 ` i2c:ocores: fixes and polling mechanism Federico Vaga
2018-08-12 15:34   ` Wolfram Sang
2018-08-22 16:16     ` Peter Korsgaard
2018-09-17 16:42       ` Wolfram Sang
2018-09-19  5:15         ` Peter Korsgaard
2018-09-19  6:51           ` Wolfram Sang

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=20180625161303.7991-3-federico.vaga@cern.ch \
    --to=federico.vaga@cern.ch \
    --cc=jacmet@sunsite.dk \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).