i2c: tegra-bpmp: Implement better error handling
Inspect a message's return value upon successful IVC transaction to determine if the I2C transaction on the BPMP side was successful. Heavily based on work by Timo Alho <talho@nvidia.com>. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
71581562ee
commit
1a0e240d09
@ -217,9 +217,34 @@ static int tegra_bpmp_i2c_msg_xfer(struct tegra_bpmp_i2c *i2c,
|
|||||||
else
|
else
|
||||||
err = tegra_bpmp_transfer(i2c->bpmp, &msg);
|
err = tegra_bpmp_transfer(i2c->bpmp, &msg);
|
||||||
|
|
||||||
|
if (err < 0) {
|
||||||
|
dev_err(i2c->dev, "failed to transfer message: %d\n", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg.rx.ret != 0) {
|
||||||
|
if (msg.rx.ret == -BPMP_EAGAIN) {
|
||||||
|
dev_dbg(i2c->dev, "arbitration lost\n");
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.rx.ret == -BPMP_ETIMEDOUT) {
|
||||||
|
dev_dbg(i2c->dev, "timeout\n");
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.rx.ret == -BPMP_ENXIO) {
|
||||||
|
dev_dbg(i2c->dev, "NAK\n");
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_err(i2c->dev, "transaction failed: %d\n", msg.rx.ret);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int tegra_bpmp_i2c_xfer_common(struct i2c_adapter *adapter,
|
static int tegra_bpmp_i2c_xfer_common(struct i2c_adapter *adapter,
|
||||||
struct i2c_msg *msgs, int num,
|
struct i2c_msg *msgs, int num,
|
||||||
bool atomic)
|
bool atomic)
|
||||||
|
Loading…
Reference in New Issue
Block a user