]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
drivers: mediatek: Fix error handling in mtk_i2c_do_transfer
authorFrancois Berder <fberder@outlook.fr>
Fri, 8 Sep 2023 16:47:46 +0000 (18:47 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 22 Sep 2023 19:54:39 +0000 (15:54 -0400)
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>
drivers/i2c/mtk_i2c.c

index 2f331d3216ae30c28368ced7d2b8c0330dc33779..5592fe9181718b5076bbed5ccd6eb992aa6626dc 100644 (file)
@@ -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)