mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/7 v3] i2c-eg20t: Fix bus-idle waiting issue
@ 2011-10-06  6:56 Tomoya MORINAGA
  2011-10-06  6:56 ` [PATCH 2/7 v3] i2c-eg20t: Modify returned value s32 to long Tomoya MORINAGA
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Tomoya MORINAGA @ 2011-10-06  6:56 UTC (permalink / raw)
  To: Jean Delvare, Ben Dooks, Wolfram Sang, Qi Wang, Linus Walleij,
	linux-i2c, linux-kernel
  Cc: yong.y.wang, joel.clark, kok.howg.ewe, Tomoya MORINAGA

Currently, when checking whether bus is idle or not,
if timeout occurs,
this function always returns success(zero).
This patch fixes the issue.

Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
---
 drivers/i2c/busses/i2c-eg20t.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
index 6565009..35d819a 100644
--- a/drivers/i2c/busses/i2c-eg20t.c
+++ b/drivers/i2c/busses/i2c-eg20t.c
@@ -275,23 +275,23 @@ static s32 pch_i2c_wait_for_bus_idle(struct i2c_algo_pch_data *adap,
 				     s32 timeout)
 {
 	void __iomem *p = adap->pch_base_address;
+	ktime_t ns_val;
+
+	if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
+		return 0;
 
 	/* MAX timeout value is timeout*1000*1000nsec */
-	ktime_t ns_val = ktime_add_ns(ktime_get(), timeout*1000*1000);
+	ns_val = ktime_add_ns(ktime_get(), timeout*1000*1000);
 	do {
-		if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
-			break;
 		msleep(20);
+		if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
+			return 0;
 	} while (ktime_lt(ktime_get(), ns_val));
 
 	pch_dbg(adap, "I2CSR = %x\n", ioread32(p + PCH_I2CSR));
+	pch_err(adap, "%s: Timeout Error.return%d\n", __func__, -ETIME);
 
-	if (timeout == 0) {
-		pch_err(adap, "%s: Timeout Error.return%d\n", __func__, -ETIME);
-		return -ETIME;
-	}
-
-	return 0;
+	return -ETIME;
 }
 
 /**
-- 
1.7.4.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-10-06  7:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-06  6:56 [PATCH 1/7 v3] i2c-eg20t: Fix bus-idle waiting issue Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 2/7 v3] i2c-eg20t: Modify returned value s32 to long Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 3/7 v1] i2c-eg20t: Fix 10bit access issue Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 3/7 v3] i2c-eg20t: delete 10bit access processing Tomoya MORINAGA
2011-10-06  7:00   ` Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 4/7 v3] i2c-eg20t: Separate error processing Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 5/7 v3] i2c-eg20t: add stop sequence in case wait-event timeout occurs Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 6/7 v3] i2c-eg20t: Fix flag setting issue Tomoya MORINAGA
2011-10-06  6:56 ` [PATCH 7/7 v3] i2c-eg20t: Add initialize processing in case i2c-error occurs Tomoya MORINAGA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®