Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294810
b: refs/heads/master
c: 0836c80
h: refs/heads/master
v: v3
  • Loading branch information
Alexander Stein authored and Wolfram Sang committed Mar 7, 2012
1 parent 0a622c4 commit 271fb96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c62c3ca55e0db52b311b1258ed08bc6c7525195e
refs/heads/master: 0836c80901565e8549e17cbad6933ab7e48ef6b2
36 changes: 21 additions & 15 deletions trunk/drivers/i2c/busses/i2c-eg20t.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,30 +271,36 @@ static inline bool ktime_lt(const ktime_t cmp1, const ktime_t cmp2)
/**
* pch_i2c_wait_for_bus_idle() - check the status of bus.
* @adap: Pointer to struct i2c_algo_pch_data.
* @timeout: waiting time counter (us).
* @timeout: waiting time counter (ms).
*/
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;
int schedule = 0;
unsigned long end = jiffies + msecs_to_jiffies(timeout);

while (ioread32(p + PCH_I2CSR) & I2CMBB_BIT) {
if (time_after(jiffies, end)) {
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 ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
return 0;
return -ETIME;
}

/* MAX timeout value is timeout*1000*1000nsec */
ns_val = ktime_add_ns(ktime_get(), timeout*1000*1000);
do {
msleep(20);
if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
return 0;
} while (ktime_lt(ktime_get(), ns_val));
if (!schedule)
/* Retry after some usecs */
udelay(5);
else
/* Wait a bit more without consuming CPU */
usleep_range(20, 1000);

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);
schedule = 1;
}

return -ETIME;
return 0;
}

/**
Expand Down

0 comments on commit 271fb96

Please sign in to comment.