Re: [PATCH v2] iio: imu: bmi323: check i2c_transfer() return value
From: Andy Shevchenko
Date: Fri Nov 20 2026 - 04:38:39 EST
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).
> 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>
--
With Best Regards,
Andy Shevchenko