]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD
authorLeilk.Liu <leilk.liu@mediatek.com>
Sat, 6 Sep 2025 08:24:06 +0000 (16:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:29 +0000 (11:56 +0200)
commit07f952d5d2fb5baefe1a2d2ec90f77697f1d4136
tree7815fa8d2980f544f7eb1994823033b33a58c0b0
parente8de297fa417d50939d2aadc756c2dfec059e0f9
i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD

[ Upstream commit b492183652808e0f389272bf63dc836241b287ff ]

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: b2ed11e224a2 ("I2C: mediatek: Add driver for MediaTek MT8173 I2C controller")
Signed-off-by: Leilk.Liu <leilk.liu@mediatek.com>
Suggested-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/busses/i2c-mt65xx.c