@@ -1288,8 +1288,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
if (!time_left && !completion_done(&i2c_dev->dma_complete)) {
dev_err(i2c_dev->dev, "DMA transfer timeout\n");
- tegra_i2c_init(i2c_dev);
- return -ETIMEDOUT;
+ err = -ETIMEDOUT;
+ goto reset_hardware;
}
if (i2c_dev->msg_read && i2c_dev->msg_err == I2C_ERR_NONE) {
@@ -1309,8 +1309,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
if (time_left == 0) {
dev_err(i2c_dev->dev, "i2c transfer timed out\n");
- tegra_i2c_init(i2c_dev);
- return -ETIMEDOUT;
+ err = -ETIMEDOUT;
+ goto reset_hardware;
}
dev_dbg(i2c_dev->dev, "transfer complete: %lu %d %d\n",
@@ -1324,6 +1324,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
return err;
return 0;
+
+reset_hardware:
+ tegra_i2c_init(i2c_dev);
+
+ return err;
}
static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],