Skip to content

Commit a74c313

Browse files
cpackham-atlnzwsakernel
authored andcommitted
i2c: mpc: Use atomic read and fix break condition
Maxime points out that the polling code in mpc_i2c_isr should use the _atomic API because it is called in an irq context and that the behaviour of the MCF bit is that it is 1 when the byte transfer is complete. All of this means the original code was effectively a udelay(100). Fix this by using readb_poll_timeout_atomic() and removing the negation of the break condition. Fixes: 4a8ac5e ("i2c: mpc: Poll for MCF") Reported-by: Maxime Bizon <[email protected]> Signed-off-by: Chris Packham <[email protected]> Tested-by: Maxime Bizon <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent b503de2 commit a74c313

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/i2c/busses/i2c-mpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ static irqreturn_t mpc_i2c_isr(int irq, void *dev_id)
636636
status = readb(i2c->base + MPC_I2C_SR);
637637
if (status & CSR_MIF) {
638638
/* Wait up to 100us for transfer to properly complete */
639-
readb_poll_timeout(i2c->base + MPC_I2C_SR, status, !(status & CSR_MCF), 0, 100);
639+
readb_poll_timeout_atomic(i2c->base + MPC_I2C_SR, status, status & CSR_MCF, 0, 100);
640640
writeb(0, i2c->base + MPC_I2C_SR);
641641
mpc_i2c_do_intr(i2c, status);
642642
return IRQ_HANDLED;

0 commit comments

Comments
 (0)