linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] i2c: tegra: Improve handling of i2c_recover_bus()
@ 2021-03-29 19:05 Dmitry Osipenko
  2021-03-29 19:15 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Osipenko @ 2021-03-29 19:05 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan, Wolfram Sang
  Cc: linux-i2c, linux-tegra, linux-kernel

The i2c_recover_bus() returns -EOPNOTSUPP if bus recovery isn't wired up,
which the case for older Tegra SoCs at the moment. This error code is then
propagated to I2C client and might be confusing, thus return -EIO instead.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/i2c/busses/i2c-tegra.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index c883044715f3..cb5e3cc96160 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1196,8 +1196,14 @@ static int tegra_i2c_error_recover(struct tegra_i2c_dev *i2c_dev,
 
 	/* start recovery upon arbitration loss in single master mode */
 	if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) {
-		if (!i2c_dev->multimaster_mode)
-			return i2c_recover_bus(&i2c_dev->adapter);
+		if (!i2c_dev->multimaster_mode) {
+			int err = i2c_recover_bus(&i2c_dev->adapter);
+
+			if (err == -EOPNOTSUPP)
+				return -EIO;
+
+			return err;
+		}
 
 		return -EAGAIN;
 	}
-- 
2.30.2


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

* Re: [PATCH v1] i2c: tegra: Improve handling of i2c_recover_bus()
  2021-03-29 19:05 [PATCH v1] i2c: tegra: Improve handling of i2c_recover_bus() Dmitry Osipenko
@ 2021-03-29 19:15 ` Wolfram Sang
  2021-03-29 19:28   ` Dmitry Osipenko
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2021-03-29 19:15 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan, linux-i2c,
	linux-tegra, linux-kernel

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

On Mon, Mar 29, 2021 at 10:05:46PM +0300, Dmitry Osipenko wrote:
> The i2c_recover_bus() returns -EOPNOTSUPP if bus recovery isn't wired up,
> which the case for older Tegra SoCs at the moment. This error code is then
> propagated to I2C client and might be confusing, thus return -EIO instead.

Hmm, makes sense. Maybe we should change it in the core? But with EBUSY
instead?


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

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

* Re: [PATCH v1] i2c: tegra: Improve handling of i2c_recover_bus()
  2021-03-29 19:15 ` Wolfram Sang
@ 2021-03-29 19:28   ` Dmitry Osipenko
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Osipenko @ 2021-03-29 19:28 UTC (permalink / raw)
  To: Wolfram Sang, Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	linux-i2c, linux-tegra, linux-kernel

29.03.2021 22:15, Wolfram Sang пишет:
> On Mon, Mar 29, 2021 at 10:05:46PM +0300, Dmitry Osipenko wrote:
>> The i2c_recover_bus() returns -EOPNOTSUPP if bus recovery isn't wired up,
>> which the case for older Tegra SoCs at the moment. This error code is then
>> propagated to I2C client and might be confusing, thus return -EIO instead.
> 
> Hmm, makes sense. Maybe we should change it in the core? But with EBUSY
> instead?
> 

This also should be a good variant. I'll update the patch, thanks.

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

end of thread, other threads:[~2021-03-29 19:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 19:05 [PATCH v1] i2c: tegra: Improve handling of i2c_recover_bus() Dmitry Osipenko
2021-03-29 19:15 ` Wolfram Sang
2021-03-29 19:28   ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).