[PATCH] drivers: mediatek: Fix error handling in mtk_i2c_do_transfer

Errors were handled only if an I2C transfer timed out and received a NACK which is very unlikely. This commit changes the condition such that errors are handled if an I2C transfer times out or received a NACK.
Signed-off-by: Francois Berder fberder@outlook.fr --- drivers/i2c/mtk_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/mtk_i2c.c b/drivers/i2c/mtk_i2c.c index 2f331d32..5592fe91 100644 --- a/drivers/i2c/mtk_i2c.c +++ b/drivers/i2c/mtk_i2c.c @@ -621,7 +621,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c_priv *priv, i2c_writel(priv, REG_INTR_MASK, ~(restart_flag | I2C_HS_NACKERR | I2C_ACKERR | I2C_TRANSAC_COMP));
- if (!tmo && trans_error != 0) { + if (tmo || trans_error != 0) { if (tmo) { ret = -ETIMEDOUT; if (!priv->filter_msg)

Hello Francois,
On 08.09.23 18:47, Francois Berder wrote:
Errors were handled only if an I2C transfer timed out and received a NACK which is very unlikely. This commit changes the condition such that errors are handled if an I2C transfer times out or received a NACK.
Signed-off-by: Francois Berder fberder@outlook.fr
drivers/i2c/mtk_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Good catch!
Reviewed-by: Heiko Schocher hs@denx.de
@Tom: Can this go into the release so late? If so, I can make a pull request...
bye, Heiko

On Thu, Sep 14, 2023 at 05:16:43PM +0200, Heiko Schocher wrote:
Hello Francois,
On 08.09.23 18:47, Francois Berder wrote:
Errors were handled only if an I2C transfer timed out and received a NACK which is very unlikely. This commit changes the condition such that errors are handled if an I2C transfer times out or received a NACK.
Signed-off-by: Francois Berder fberder@outlook.fr
drivers/i2c/mtk_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Good catch!
Reviewed-by: Heiko Schocher hs@denx.de
@Tom: Can this go into the release so late? If so, I can make a pull request...
I'll pick it up, thanks.

On Fri, Sep 08, 2023 at 06:47:46PM +0200, Francois Berder wrote:
Errors were handled only if an I2C transfer timed out and received a NACK which is very unlikely. This commit changes the condition such that errors are handled if an I2C transfer times out or received a NACK.
Signed-off-by: Francois Berder fberder@outlook.fr Reviewed-by: Heiko Schocher hs@denx.de
Applied to u-boot/master, thanks!
participants (3)
-
Francois Berder
-
Heiko Schocher
-
Tom Rini