diff options
author | Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com> | 2011-10-12 00:13:00 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-10-29 06:09:32 -0400 |
commit | 93e4ad74da14c8d5564cfc0b57c40ca311e53d47 (patch) | |
tree | 190708ec41707f3bdae87b68ddaa299b86b43f4d /drivers/i2c | |
parent | 1fdb24e969110fafea36d3b393bea438f702c87f (diff) |
i2c-eg20t: Fix bus-idle waiting issue
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>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | 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 ce1a32b71e47..a4f76cb76c46 100644 --- a/drivers/i2c/busses/i2c-eg20t.c +++ b/drivers/i2c/busses/i2c-eg20t.c | |||
@@ -273,23 +273,23 @@ static s32 pch_i2c_wait_for_bus_idle(struct i2c_algo_pch_data *adap, | |||
273 | s32 timeout) | 273 | s32 timeout) |
274 | { | 274 | { |
275 | void __iomem *p = adap->pch_base_address; | 275 | void __iomem *p = adap->pch_base_address; |
276 | ktime_t ns_val; | ||
277 | |||
278 | if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0) | ||
279 | return 0; | ||
276 | 280 | ||
277 | /* MAX timeout value is timeout*1000*1000nsec */ | 281 | /* MAX timeout value is timeout*1000*1000nsec */ |
278 | ktime_t ns_val = ktime_add_ns(ktime_get(), timeout*1000*1000); | 282 | ns_val = ktime_add_ns(ktime_get(), timeout*1000*1000); |
279 | do { | 283 | do { |
280 | if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0) | ||
281 | break; | ||
282 | msleep(20); | 284 | msleep(20); |
285 | if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0) | ||
286 | return 0; | ||
283 | } while (ktime_lt(ktime_get(), ns_val)); | 287 | } while (ktime_lt(ktime_get(), ns_val)); |
284 | 288 | ||
285 | pch_dbg(adap, "I2CSR = %x\n", ioread32(p + PCH_I2CSR)); | 289 | pch_dbg(adap, "I2CSR = %x\n", ioread32(p + PCH_I2CSR)); |
290 | pch_err(adap, "%s: Timeout Error.return%d\n", __func__, -ETIME); | ||
286 | 291 | ||
287 | if (timeout == 0) { | 292 | return -ETIME; |
288 | pch_err(adap, "%s: Timeout Error.return%d\n", __func__, -ETIME); | ||
289 | return -ETIME; | ||
290 | } | ||
291 | |||
292 | return 0; | ||
293 | } | 293 | } |
294 | 294 | ||
295 | /** | 295 | /** |