Skip to contentSkip to conversation

i2c: tegra: Improve handling of i2c_recover_bus()

PATCH In review Dmitry Osipenko 2 participants 3 messages Mar 29, 2021

Subsystems (3)
lore
Share & tools
lore

Dmitry Osipenko

author reviewer
#0 lore raw

PATCH 1/1 i2c: tegra: Improve handling of i2c_recover_bus()

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.

---
 drivers/i2c/busses/i2c-tegra.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-tegra.c +8 -2
index c883044715f3..cb5e3cc96160 100644
@@ -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;
 	}
Signature · 1 line
2.30.2
#1 lore raw
Quoted 3 lines · Dmitry Osipenko

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?

author reviewer
#2 lore raw

29.03.2021 22:15, Wolfram Sang пишет:

Quoted 8 lines · Dmitry Osipenko
Quoted 3 lines

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.