Re: [PATCH 1/1] Input: atmel_mxt_ts - implement I2C retries

From: Dmitry Osipenko
Date: Thu Sep 03 2020 - 11:07:04 EST


03.09.2020 17:44, Wang, Jiada пишет:
> Hi Dmitry
>
...
>> Is it really possible to get a positive ret != 2 from i2c_transfer()?
>>
>> Maybe it's better to keep the old code behaviour by returning the "ret"
>> value directly if it's not equal to ARRAY_SIZE(xfer)?
>>
> I think, theoretically i2c_transfer() may return positive value but !=
> number to transfer,
> original behavior is,
> when ret >= 0, it returns -EIO, when ret < 0, it just returns ret,
>
> current behavior is, when ret != 2, it returns -EIO, after retry.
>
> I am OK to change the behavior exactly as same original one.

The comment to i2c_transfer() says that it either returns a error code
or number of executed messages. But it's not clear to me what I2C driver
could return 0 or 1 here and why.

I think it indeed should be better to keep the original behaviour by
propagating the actual error code whenever possible. It's probably not
critical for this particular case, but in general it's always better to
preserve the original error code.