Re: [PATCH v2] iio: imu: bmi323: check i2c_transfer() return value
From: Jonathan Cameron
Date: Sat Nov 21 2026 - 17:07:08 EST
On Fri, 20 Nov 2026 11:38:21 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> On Fri, Nov 20, 2026 at 10:21:43AM +0800, Siqi Chen wrote:
> > i2c_transfer() returns the number of messages transferred or a negative
> > error code. The BMI323 I2C read path only checks for negative values and
> > maps all errors to -EIO.
> >
> > If only the register-address message is transferred, the function copies
> > data from the receive buffer and reports success even though the read
> > message was not completed.
> >
> > Require both messages to be transferred, preserve negative error codes,
> > and return -EIO for a short transfer.
>
> > OpenCode was used to identify the issue and draft the code and changelog.
>
> This line should be in the comment block, behind the '---' line.
> No need to resend (just remember for the future submissions).
This time I took this and dropped that bit whilst doing so.
Applied to the testing branch of iio.git as not high urgency.
In practice short reads only occur in very very rare circumstances.
Thanks
Jonathan
>
> > Fixes: 8a636db3aa57 ("iio: imu: Add driver for BMI323 IMU")
> > Signed-off-by: Siqi Chen <chensiqi@xxxxxxxxxxxxx>
> > ---
> > Changes in v2:
> > - Split the transfer error and short-transfer checks for readability.
> > - Move testing information below the separator.
> >
> > Compile-tested with CONFIG_BMI323_I2C=m using:
> >
> > make O=/tmp/opencode/linux-build-bmi323 W=1 \
> > drivers/iio/imu/bmi323/bmi323_i2c.o
> >
> > No hardware or I2C fault-injection testing was performed.
>
> Code wise LGTM.
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>