From mboxrd@z Thu Jan 1 00:00:00 1970 From: Federico Vaga Subject: [PATCH v3 2/5] i2c:ocores: do not handle IRQ if IF is not set Date: Fri, 8 Feb 2019 17:11:58 +0100 Message-ID: <20190208161201.7860-3-federico.vaga@cern.ch> References: <20190208161201.7860-1-federico.vaga@cern.ch> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <20190208161201.7860-1-federico.vaga@cern.ch> Sender: linux-kernel-owner@vger.kernel.org To: Peter Korsgaard , Andrew Lunn Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Federico Vaga List-Id: linux-i2c@vger.kernel.org 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 Acked-by: Peter Korsgaard --- 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 aa85202..fcc2558 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c @@ -143,10 +143,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); unsigned long flags; /* @@ -223,8 +222,12 @@ out: static irqreturn_t ocores_isr(int irq, void *dev_id) { struct ocores_i2c *i2c = dev_id; + u8 stat = oc_getreg(i2c, OCI2C_STATUS); + + if (!(stat & OCI2C_STAT_IF)) + return IRQ_NONE; - ocores_process(i2c); + ocores_process(i2c, stat); return IRQ_HANDLED; } -- 2.15.0