Re: [PATCH v7 1/7] iio: dac: ad5696: properly check i2c_transfer() return value
From: Jonathan Cameron
Date: Sat Jul 11 2026 - 21:58:53 EST
On Fri, 10 Jul 2026 12:20:45 +0100
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@xxxxxxxxxx> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@xxxxxxxxxx>
>
> Verify that the expected number of i2c messages were transferred when
> ad5686_i2c_read() is called. This issue exists since the support for I2C
> devices where first introduced.
>
> Fixes: 4177381b4401 ("iio:dac:ad5686: Add AD5671R/75R/94/94R/95R/96/96R support")
> Reported-by: sashiko-bot@xxxxxxxxxx
> Closes: https://lore.kernel.org/all/20260705114746.1485F1F000E9@xxxxxxxxxxxxxxx/
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@xxxxxxxxxx>
FWIW, as I understand it, these are vanishingly rare unless the device is
doing something unusual so I'll leave this for merge with the rest of the series.
Jonathan
> ---
> drivers/iio/dac/ad5696-i2c.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
> index 279309329b64..6f726e6301a6 100644
> --- a/drivers/iio/dac/ad5696-i2c.c
> +++ b/drivers/iio/dac/ad5696-i2c.c
> @@ -40,8 +40,8 @@ static int ad5686_i2c_read(struct ad5686_state *st, u8 addr)
> 0x00);
>
> ret = i2c_transfer(i2c->adapter, msg, 2);
> - if (ret < 0)
> - return ret;
> + if (ret != 2)
> + return ret < 0 ? ret : -EIO;
>
> return be16_to_cpu(st->data[0].d16);
> }
>