summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2021-03-23 16:57:13 +0100
committerWolfram Sang <wsa@kernel.org>2021-03-31 09:52:23 +0200
commit1a0e240d09413ac6c90ce6247afdfc424c84103f (patch)
treecd36fa2b93228f6afa716e69257a47b488d77ed5
parent71581562ee36032d2d574a9b23ad4af6d6a64cf7 (diff)
downloadlinux-stable-1a0e240d09413ac6c90ce6247afdfc424c84103f.tar.gz
linux-stable-1a0e240d09413ac6c90ce6247afdfc424c84103f.tar.bz2
linux-stable-1a0e240d09413ac6c90ce6247afdfc424c84103f.zip
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>
-rw-r--r--drivers/i2c/busses/i2c-tegra-bpmp.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-tegra-bpmp.c b/drivers/i2c/busses/i2c-tegra-bpmp.c
index c0c7d01473f2..c934d636f625 100644
--- a/drivers/i2c/busses/i2c-tegra-bpmp.c
+++ b/drivers/i2c/busses/i2c-tegra-bpmp.c
@@ -217,7 +217,32 @@ static int tegra_bpmp_i2c_msg_xfer(struct tegra_bpmp_i2c *i2c,
else
err = tegra_bpmp_transfer(i2c->bpmp, &msg);
- return err;
+ if (err < 0) {
+ dev_err(i2c->dev, "failed to transfer message: %d\n", 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,