OSDN Git Service

i2c: rcar: cleanup DMA for all kinds of failure
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Fri, 19 Oct 2018 19:15:26 +0000 (21:15 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Sat, 20 Oct 2018 13:25:59 +0000 (15:25 +0200)
DMA needs to be cleaned up not only on timeout, but on all errors where
it has been setup before.

Fixes: 73e8b0528346 ("i2c: rcar: add DMA support")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-rcar.c

index 52cf42b..4aa7dde 100644 (file)
@@ -806,8 +806,12 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
 
        time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE,
                                     num * adap->timeout);
-       if (!time_left) {
+
+       /* cleanup DMA if it couldn't complete properly due to an error */
+       if (priv->dma_direction != DMA_NONE)
                rcar_i2c_cleanup_dma(priv);
+
+       if (!time_left) {
                rcar_i2c_init(priv);
                ret = -ETIMEDOUT;
        } else if (priv->flags & ID_NACK) {