Skip to content

Commit

Permalink
i2c: ocores: do not handle IRQ if IF is not set
Browse files Browse the repository at this point in the history
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>
Acked-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Federico Vaga authored and Wolfram Sang committed Feb 14, 2019
1 parent e7663ef commit 2dc9834
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/i2c/busses/i2c-ocores.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down Expand Up @@ -223,8 +222,12 @@ 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);

if (!(stat & OCI2C_STAT_IF))
return IRQ_NONE;

ocores_process(i2c);
ocores_process(i2c, stat);

return IRQ_HANDLED;
}
Expand Down

0 comments on commit 2dc9834

Please sign in to comment.