All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: tegra: bpmp: Implement better error handling
@ 2021-03-23 15:57 Thierry Reding
  2021-03-31  7:35 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2021-03-23 15:57 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Jon Hunter, Timo Alho, linux-i2c, linux-tegra

From: Thierry Reding <treding@nvidia.com>

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>
---
 drivers/i2c/busses/i2c-tegra-bpmp.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i2c: tegra: bpmp: Implement better error handling
  2021-03-23 15:57 [PATCH] i2c: tegra: bpmp: Implement better error handling Thierry Reding
@ 2021-03-31  7:35 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2021-03-31  7:35 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jon Hunter, Timo Alho, linux-i2c, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 408 bytes --]

On Tue, Mar 23, 2021 at 04:57:13PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> 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>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-31  7:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 15:57 [PATCH] i2c: tegra: bpmp: Implement better error handling Thierry Reding
2021-03-31  7:35 ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.