[PATCH] i2c: imx: keep the error of a failed read

Stefan Eichenberger eichest at gmail.com
Mon Nov 16 10:25:01 PST 2026


On Mon, Nov 16, 2026 at 01:59:40PM +0100, Mehmet Fide wrote:
> From: Mehmet Fide <mehmet.fide at screeningeagle.com>
> 
> When the count byte of an SMBus block read is larger than
> I2C_SMBUS_BLOCK_MAX, i2c_imx_isr_read_block_data_len() sets -EPROTO and
> fails the read. The read of I2DR that took the count byte has started
> the reception of one more byte, and its interrupt comes in while the
> state is IMX_I2C_STATE_FAILED. i2c_imx_master_isr() has no case for
> that state, so the default case replaces -EPROTO with -EINVAL.
> 
> Ignore interrupts in IMX_I2C_STATE_FAILED so that the first error is
> returned.
> 
> Fixes: 5f5c2d4579ca ("i2c: imx: prevent rescheduling in non dma mode")
> Signed-off-by: Mehmet Fide <mehmet.fide at screeningeagle.com>
> ---
> 
> Notes:
>     Tested on a Colibri VF50 on the Iris carrier, kernel at this base plus
>     "i2c: imx: acknowledge the count byte of an atomic block read" and
>     "i2c: imx: do not acknowledge the last byte of a block read of one
>     byte", with the M41T0 RTC at 0x68. A test-only hook passed the messages
>     that i2c_smbus_xfer_emulated() builds for a block read to the adapter,
>     alone and followed by a one byte read. Register 0x03 (0xae) as count
>     byte: without the patch -EINVAL 40 of 40, and a print in the default
>     case showed state IMX_I2C_STATE_FAILED with -EPROTO each time; with it
>     -EPROTO 100 of 100, as the atomic read returns. Count bytes of 0, 1 and
>     0x13 read the same bytes as before, and the bus works after each
>     failed read.
> 
>  drivers/i2c/busses/i2c-imx.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index ccf08cd63151..c7fef98934d4 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1142,6 +1142,9 @@ static irqreturn_t i2c_imx_master_isr(struct imx_i2c_struct *i2c_imx, unsigned i
>  		wake_up(&i2c_imx->queue);
>  		break;
>  
> +	case IMX_I2C_STATE_FAILED:
> +		break;
> +
>  	default:
>  		i2c_imx->i2csr = status;
>  		i2c_imx->state = IMX_I2C_STATE_FAILED;
> 
> base-commit: 25e7ab89f4774b0f842cee0e8a20c11f755924d5
> -- 
> 2.56.0

Looks good as well, thanks.

Reviewed-by: Stefan Eichenberger <eichest at gmail.com>



More information about the linux-arm-kernel mailing list