mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
To: Jean Delvare <khali@linux-fr.org>,
	Ben Dooks <ben-linux@fluff.org>,
	Wolfram Sang <w.sang@pengutronix.de>, Qi Wang <qi.wang@intel.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: yong.y.wang@intel.com, joel.clark@intel.com,
	kok.howg.ewe@intel.com, toshiharu-linux@dsn.lapis-semi.com,
	Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
Subject: [PATCH 7/7 v2] i2c-eg20t: Fix bus-idle waiting issue
Date: Wed,  5 Oct 2011 13:17:44 +0900	[thread overview]
Message-ID: <1317788264-13118-7-git-send-email-tomoya-linux@dsn.lapis-semi.com> (raw)
In-Reply-To: <1317788264-13118-1-git-send-email-tomoya-linux@dsn.lapis-semi.com>

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>
---
v2: "[PATCH] i2c-eg20t: Fix bus-idle waiting issue" was invalid patch.
---
 drivers/i2c/busses/i2c-eg20t.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
index cf64e21..2f961b3 100644
--- a/drivers/i2c/busses/i2c-eg20t.c
+++ b/drivers/i2c/busses/i2c-eg20t.c
@@ -273,24 +273,24 @@ 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);
+	pch_i2c_init(adap);
 
-	if (timeout == 0) {
-		pch_err(adap, "%s: Timeout Error.return%d\n", __func__, -ETIME);
-		pch_i2c_init(adap);
-		return -ETIME;
-	}
-
-	return 0;
+	return -ETIME;
 }
 
 /**
-- 
1.7.6.4


      parent reply	other threads:[~2011-10-05  4:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05  4:17 [PATCH 1/7 v2] i2c-eg20t: Modify returned value s32 to long Tomoya MORINAGA
2011-10-05  4:17 ` [PATCH 2/7 v2] i2c-eg20t: delete 10bit access processing Tomoya MORINAGA
2011-10-05 17:29   ` Jeffrey (Sheng-Hui) Chu
2011-10-06  6:42     ` Tomoya MORINAGA
2011-10-05  4:17 ` [PATCH 3/7 v2] i2c-eg20t: Separate error processing Tomoya MORINAGA
2011-10-05  4:17 ` [PATCH 4/7 v2] i2c-eg20t: add stop sequence in case wait-event timeout occurs Tomoya MORINAGA
2011-10-05  4:17 ` [PATCH 5/7 v2] i2c-eg20t: Fix flag setting issue Tomoya MORINAGA
2011-10-05  4:17 ` [PATCH 6/7 v2] i2c-eg20t: Add initialize processing in case i2c-error occurs Tomoya MORINAGA
2011-10-05  4:17 ` Tomoya MORINAGA [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317788264-13118-7-git-send-email-tomoya-linux@dsn.lapis-semi.com \
    --to=tomoya-linux@dsn.lapis-semi.com \
    --cc=ben-linux@fluff.org \
    --cc=joel.clark@intel.com \
    --cc=khali@linux-fr.org \
    --cc=kok.howg.ewe@intel.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qi.wang@intel.com \
    --cc=toshiharu-linux@dsn.lapis-semi.com \
    --cc=w.sang@pengutronix.de \
    --cc=yong.y.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®