From: Wolfram Sang on
On Thu, May 27, 2010 at 01:36:27PM +0200, Marc Kleine-Budde wrote:
> The i2c_imx_trx_complete() function is using
> wait_event_interruptible_timeout() to wait for the I2C controller to
> signal that it has completed an I2C bus operation. If the process that
> causes the I2C operation receives a signal, the wait will be
> interrupted, returning an error. It is better to let the I2C operation
> finished before handling the signal (i.e. returning into userspace).
>
> It is safe to use wait_event_timeout() instead, because the timeout
> will allow the process to exit if the I2C bus hangs. It's also better
> to allow the I2C operation to finish, because unacknowledged I2C
> operations can cause the I2C bus to hang.
>
> Signed-off-by: Marc Kleine-Budde <mkl(a)pengutronix.de>
> ---
> drivers/i2c/busses/i2c-imx.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index d1ff940..d7051fe 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -161,7 +161,7 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx)
> {
> int result;
>
> - result = wait_event_interruptible_timeout(i2c_imx->queue,
> + result = wait_event_timeout(i2c_imx->queue,
> i2c_imx->i2csr & I2SR_IIF, HZ / 10);
>
> if (unlikely(result < 0)) {

That 'if' can go, too. wait_event_timeout does not return neg values.

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |