Skip to content

Commit

Permalink
i2c-imx: fix error handling
Browse files Browse the repository at this point in the history
- Return -ETIMEDOUT on bus busy error
- Fix timeout test "time_after(jiffies, orig_jiffies + HZ / 1000)" :
  By default, HZ=100 on arm. This means that this test has no chances to
  work and may result in a dead loop. Set timeout to 500ms.
- Don't try to send a new message if we failed to transmit
  previous one. This was preventing to recover from error on my system

Signed-off-by: Arnaud Patard <apatard@mandriva.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Arnaud Patard authored and Ben Dooks committed Apr 20, 2010
1 parent 01bf0b6 commit da9c99f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/i2c/busses/i2c-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
"<%s> I2C Interrupted\n", __func__);
return -EINTR;
}
if (time_after(jiffies, orig_jiffies + HZ / 1000)) {
if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) {
dev_dbg(&i2c_imx->adapter.dev,
"<%s> I2C bus is busy\n", __func__);
return -EIO;
return -ETIMEDOUT;
}
schedule();
}
Expand Down Expand Up @@ -444,6 +444,8 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
result = i2c_imx_read(i2c_imx, &msgs[i]);
else
result = i2c_imx_write(i2c_imx, &msgs[i]);
if (result)
goto fail0;
}

fail0:
Expand Down

0 comments on commit da9c99f

Please sign in to comment.