[PATCH] i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD

Chen-Yu Tsai wenst at chromium.org
Sun Aug 17 20:53:10 PDT 2025


On Sat, Aug 16, 2025 at 3:55 PM Leilk Liu <leilk.liu at mediatek.com> wrote:
>
> From: "Leilk.Liu" <leilk.liu at mediatek.com>
>
> The old IC does not support the I2C_MASTER_WRRD (write-then-read)
> function, but the current code’s handling of i2c->auto_restart may
> potentially lead to entering the I2C_MASTER_WRRD software flow,
> resulting in unexpected bugs.
>
> Instead of repurposing the auto_restart flag, add a separate flag
> to signal I2C_MASTER_WRRD operations.
>
> Also fix handling of msgs. If the operation (i2c->op) is
> I2C_MASTER_WRRD, then the msgs pointer is incremented by 2.
> For all other operations, msgs is simply incremented by 1.
>
> Fixes: 173b77e8d8fe ("i2c: mediatek: add i2c first write then read optimization")
>
> Signed-off-by: Leilk.Liu <leilk.liu at mediatek.com>

This was

Suggested-by: Chen-Yu Tsai <wenst at chromium.org>

internally because the code looked funny.

Reviewed-by: Chen-Yu Tsai <wenst at chromium.org>



More information about the Linux-mediatek mailing list