Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308454
b: refs/heads/master
c: 199bca2
h: refs/heads/master
v: v3
  • Loading branch information
Tomoya MORINAGA authored and Wolfram Sang committed May 12, 2012
1 parent 08df898 commit 2754e5a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 44 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: 5cc056327ae3a3fac7411691c27ac61be2c55957
refs/heads/master: 199bca2a72a3a5cd71401b4f12171393742be84a
65 changes: 22 additions & 43 deletions trunk/drivers/i2c/busses/i2c-eg20t.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,33 +316,6 @@ static void pch_i2c_start(struct i2c_algo_pch_data *adap)
pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_START);
}

/**
* pch_i2c_wait_for_xfer_complete() - initiates a wait for the tx complete event
* @adap: Pointer to struct i2c_algo_pch_data.
*/
static s32 pch_i2c_wait_for_xfer_complete(struct i2c_algo_pch_data *adap)
{
long ret;
ret = wait_event_timeout(pch_event,
(adap->pch_event_flag != 0), msecs_to_jiffies(1000));

if (ret == 0) {
pch_err(adap, "timeout: %x\n", adap->pch_event_flag);
adap->pch_event_flag = 0;
return -ETIMEDOUT;
}

if (adap->pch_event_flag & I2C_ERROR_MASK) {
pch_err(adap, "error bits set: %x\n", adap->pch_event_flag);
adap->pch_event_flag = 0;
return -EIO;
}

adap->pch_event_flag = 0;

return 0;
}

/**
* pch_i2c_getack() - to confirm ACK/NACK
* @adap: Pointer to struct i2c_algo_pch_data.
Expand Down Expand Up @@ -375,27 +348,33 @@ static void pch_i2c_stop(struct i2c_algo_pch_data *adap)

static int pch_i2c_wait_for_check_xfer(struct i2c_algo_pch_data *adap)
{
int rtn;

rtn = pch_i2c_wait_for_xfer_complete(adap);
if (rtn == 0) {
if (pch_i2c_getack(adap)) {
pch_dbg(adap, "Receive NACK for slave address"
"setting\n");
return -EIO;
}
} else if (rtn == -EIO) { /* Arbitration Lost */
long ret;

ret = wait_event_timeout(pch_event,
(adap->pch_event_flag != 0), msecs_to_jiffies(1000));
if (!ret) {
pch_err(adap, "%s:wait-event timeout\n", __func__);
adap->pch_event_flag = 0;
pch_i2c_stop(adap);
pch_i2c_init(adap);
return -ETIMEDOUT;
}

if (adap->pch_event_flag & I2C_ERROR_MASK) {
pch_err(adap, "Lost Arbitration\n");
adap->pch_event_flag = 0;
pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMAL_BIT);
pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT);
pch_i2c_init(adap);
return -EAGAIN;
} else { /* wait-event timeout */
pch_err(adap, "%s(L.%d):wait-event timeout\n",
__func__, __LINE__);
pch_i2c_stop(adap);
pch_i2c_init(adap);
return -ETIME;
}

adap->pch_event_flag = 0;

if (pch_i2c_getack(adap)) {
pch_dbg(adap, "Receive NACK for slave address"
"setting\n");
return -EIO;
}

return 0;
Expand Down

0 comments on commit 2754e5a

Please sign in to comment.