Re: Fwd: [PATCH 1/7] I2c-nomadik: Fix the usage ofwait_for_completion_timeout

From: Srinidhi Kasagar
Date: Thu Nov 15 2012 - 03:50:29 EST


[...]

> From: Chuansheng Liu <chuansheng.liu@xxxxxxxxx>
> Date: Tue, Nov 6, 2012 at 6:18 PM
> Subject: [PATCH 1/7] I2c-nomadik: Fix the usage of wait_for_completion_timeout
> To: linus.walleij@xxxxxxxxxx, w.sang@xxxxxxxxxxxxxx
> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx,
> linux-kernel@xxxxxxxxxxxxxxx, chuansheng.liu@xxxxxxxxx
>
>
>
> The return value of wait_for_completion_timeout() is always
> >= 0 with unsigned int type.
>
> So the condition "ret < 0" or "ret >= 0" is pointless.
>
> Signed-off-by: liu chuansheng <chuansheng.liu@xxxxxxxxx>
> ---
> drivers/i2c/busses/i2c-nomadik.c | 14 --------------
> 1 files changed, 0 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
> index 02c3115..8b2ffcf 100644
> --- a/drivers/i2c/busses/i2c-nomadik.c
> +++ b/drivers/i2c/busses/i2c-nomadik.c
> @@ -435,13 +435,6 @@ static int read_i2c(struct nmk_i2c_dev *dev, u16 flags)
> timeout = wait_for_completion_timeout(
> &dev->xfer_complete, dev->adap.timeout);
>
> - if (timeout < 0) {
> - dev_err(&dev->adev->dev,
> - "wait_for_completion_timeout "
> - "returned %d waiting for event\n", timeout);
> - status = timeout;
> - }
> -
No, it is wrong. You need to update the status variable in the case of timeout.
It is used further in nmk_i2c_xfer_one. You could perhaps use

if (timeout == 0) {
...and the rest of the code as is
}

regards/srinidhi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/