Re: [PATCH] i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD
From: Chen-Yu Tsai
Date: Sun Aug 17 2025 - 23:53:33 EST
On Sat, Aug 16, 2025 at 3:55 PM Leilk Liu <leilk.liu@xxxxxxxxxxxx> wrote:
>
> From: "Leilk.Liu" <leilk.liu@xxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxx>
This was
Suggested-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
internally because the code looked funny.
Reviewed-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>