From 3edaed5a61fc9b6711d2efc5efbb4fa17be770ab Mon Sep 17 00:00:00 2001 From: "myung-su.cha" Date: Tue, 3 Apr 2018 14:11:22 +0900 Subject: [PATCH] [COMMON] i2c: exynos5: fix Tx sequence of i2c_xfer_msg Interrupt routine and Polling routine of Tx are carried out twice unnecessarilly. Therefore, This patch combines it one Interrupt and Polling routine. Change-Id: If8443009a50c94c5a6d0b34f9ffa921d1d48b680 Signed-off-by: myung-su.cha --- drivers/i2c/busses/i2c-exynos5.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index 54c91aadc8dd..79eb15eb600f 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -831,6 +831,8 @@ static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c, } } else { if (operation_mode == HSI2C_POLLING) { + unsigned long int_status; + unsigned long fifo_status; timeout = jiffies + EXYNOS5_I2C_TIMEOUT; while (time_before(jiffies, timeout) && (i2c->msg_ptr < i2c->msg->len)) { @@ -840,24 +842,6 @@ static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c, writel(byte, i2c->regs + HSI2C_TX_DATA); } } - } else { - timeout = wait_for_completion_timeout - (&i2c->msg_complete, EXYNOS5_I2C_TIMEOUT); - disable_irq(i2c->irq); - - if (timeout == 0) { - dump_i2c_register(i2c); - exynos5_i2c_reset(i2c); - dev_warn(i2c->dev, "tx timeout\n"); - return ret; - } - - timeout = jiffies + timeout; - } - - if (operation_mode == HSI2C_POLLING) { - unsigned long int_status; - unsigned long fifo_status; while (time_before(jiffies, timeout)) { int_status = readl(i2c->regs + HSI2C_INT_STATUS); fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); @@ -876,6 +860,18 @@ static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c, return ret; } } else { + timeout = wait_for_completion_timeout + (&i2c->msg_complete, EXYNOS5_I2C_TIMEOUT); + disable_irq(i2c->irq); + + if (timeout == 0) { + dump_i2c_register(i2c); + exynos5_i2c_reset(i2c); + dev_warn(i2c->dev, "tx timeout\n"); + return ret; + } + + timeout = jiffies + timeout; if (i2c->trans_done < 0) { dev_err(i2c->dev, "ack was not received at write\n"); ret = i2c->trans_done; -- 2.20.1