mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg()
Factor out error recovery code from tegra_i2c_xfer_msg() in order to make this function easier to read and follow. Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Tested-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
e57ac5aba0
commit
4a8e0f8797
@ -1105,6 +1105,32 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap)
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
static int tegra_i2c_error_recover(struct tegra_i2c_dev *i2c_dev,
|
||||
struct i2c_msg *msg)
|
||||
{
|
||||
if (i2c_dev->msg_err == I2C_ERR_NONE)
|
||||
return 0;
|
||||
|
||||
tegra_i2c_init(i2c_dev);
|
||||
|
||||
/* start recovery upon arbitration loss in single master mode */
|
||||
if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) {
|
||||
if (!i2c_dev->is_multimaster_mode)
|
||||
return i2c_recover_bus(&i2c_dev->adapter);
|
||||
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
|
||||
if (msg->flags & I2C_M_IGNORE_NAK)
|
||||
return 0;
|
||||
|
||||
return -EREMOTEIO;
|
||||
}
|
||||
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
|
||||
struct i2c_msg *msg,
|
||||
enum msg_end_type end_state)
|
||||
@ -1288,24 +1314,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
|
||||
i2c_dev->msg_err);
|
||||
|
||||
i2c_dev->is_curr_dma_xfer = false;
|
||||
if (i2c_dev->msg_err == I2C_ERR_NONE)
|
||||
return 0;
|
||||
|
||||
tegra_i2c_init(i2c_dev);
|
||||
/* start recovery upon arbitration loss in single master mode */
|
||||
if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) {
|
||||
if (!i2c_dev->is_multimaster_mode)
|
||||
return i2c_recover_bus(&i2c_dev->adapter);
|
||||
return -EAGAIN;
|
||||
}
|
||||
err = tegra_i2c_error_recover(i2c_dev, msg);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
|
||||
if (msg->flags & I2C_M_IGNORE_NAK)
|
||||
return 0;
|
||||
return -EREMOTEIO;
|
||||
}
|
||||
|
||||
return -EIO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
|
||||
|
Loading…
Reference in New Issue
Block a user