i2c: designware: report short transfers
authorRussell King <rmk+kernel@armlinux.org.uk>
Fri, 18 Nov 2016 19:40:04 +0000 (19:40 +0000)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 24 Nov 2016 15:17:34 +0000 (16:17 +0100)
Rather than reporting success for a short transfer due to interrupt
latency, report an error both to the caller, as well as to the kernel
log.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-designware-core.c

index 11e866d053680e5af3ba5a06dbaf078700724aa5..066a2ba6aeda91fd71b1fb6a160eda92ab4a102f 100644 (file)
@@ -758,7 +758,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
        }
 
        /* no error */
-       if (likely(!dev->cmd_err)) {
+       if (likely(!dev->cmd_err && !dev->status)) {
                ret = num;
                goto done;
        }
@@ -768,6 +768,11 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
                ret = i2c_dw_handle_tx_abort(dev);
                goto done;
        }
+
+       if (dev->status)
+               dev_err(dev->dev,
+                       "transfer terminated early - interrupt latency too high?\n");
+
        ret = -EIO;
 
 done: