Skip to content

Commit 263fe5d

Browse files
jaehyooWolfram Sang
authored andcommitted
i2c: aspeed: Adjust spinlock scope in the irq handler
This patch adjusts spinlock scope to make it wrap the whole irq handler using a single lock/unlock which covers both master and slave handlers. Signed-off-by: Jae Hyun Yoo <[email protected]> Reviewed-by: Brendan Higgins <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 517fde0 commit 263fe5d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/i2c/busses/i2c-aspeed.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ static bool aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus)
234234
bool irq_handled = true;
235235
u8 value;
236236

237-
spin_lock(&bus->lock);
238237
if (!slave) {
239238
irq_handled = false;
240239
goto out;
@@ -325,7 +324,6 @@ static bool aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus)
325324
writel(status_ack, bus->base + ASPEED_I2C_INTR_STS_REG);
326325

327326
out:
328-
spin_unlock(&bus->lock);
329327
return irq_handled;
330328
}
331329
#endif /* CONFIG_I2C_SLAVE */
@@ -389,7 +387,6 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
389387
u8 recv_byte;
390388
int ret;
391389

392-
spin_lock(&bus->lock);
393390
irq_status = readl(bus->base + ASPEED_I2C_INTR_STS_REG);
394391
/* Ack all interrupt bits. */
395392
writel(irq_status, bus->base + ASPEED_I2C_INTR_STS_REG);
@@ -547,22 +544,29 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
547544
dev_err(bus->dev,
548545
"irq handled != irq. expected 0x%08x, but was 0x%08x\n",
549546
irq_status, status_ack);
550-
spin_unlock(&bus->lock);
551547
return !!irq_status;
552548
}
553549

554550
static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id)
555551
{
556552
struct aspeed_i2c_bus *bus = dev_id;
553+
bool ret;
554+
555+
spin_lock(&bus->lock);
557556

558557
#if IS_ENABLED(CONFIG_I2C_SLAVE)
559558
if (aspeed_i2c_slave_irq(bus)) {
560559
dev_dbg(bus->dev, "irq handled by slave.\n");
561-
return IRQ_HANDLED;
560+
ret = true;
561+
goto out;
562562
}
563563
#endif /* CONFIG_I2C_SLAVE */
564564

565-
return aspeed_i2c_master_irq(bus) ? IRQ_HANDLED : IRQ_NONE;
565+
ret = aspeed_i2c_master_irq(bus);
566+
567+
out:
568+
spin_unlock(&bus->lock);
569+
return ret ? IRQ_HANDLED : IRQ_NONE;
566570
}
567571

568572
static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,

0 commit comments

Comments
 (0)