Skip to contentSkip to conversation

i2c-hix5hd2: Add more debug info when transfer fail.

PATCH In review Tao Lan 2 participants 2 messages Sep 30, 2022 – Jun 10, 2023 I2C subsystem host drivers

lore
Share & tools
lore

Tao Lan

author
#0 lore raw

PATCH 1/1 i2c-hix5hd2: Add more debug info when transfer fail.

From: taolan <[email protected]>

The transfer result is checked, classified, and printed, which facilitates debugging.

---
 drivers/i2c/busses/i2c-hix5hd2.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-hix5hd2.c +10 -1
index 61ae58f57047..e6ab8b20cd01 100644
@@ -366,8 +366,17 @@ static int hix5hd2_i2c_xfer(struct i2c_adapter *adap,
 			goto out;
 	}
 
-	ret = num;
+	if (i == num) {
+		ret = num;
+	} else {
+		/* Only one message, cannot access the device */
+		if (i == 1)
+			ret = -EREMOTEIO;
+		else
+			ret = i;
 
+		pr_warning("xfer message failed\n");
+	}
 out:
 	pm_runtime_mark_last_busy(priv->dev);
 	pm_runtime_put_autosuspend(priv->dev);
Signature · 1 line
2.22.0
maintainer
#1 lore raw

Hi Taolan,

Quoted 4 lines · Tao Lan

From: taolan <[email protected]>

The transfer result is checked, classified, and printed, which facilitates debugging.

you are missing your Signed-off-by here.

Quoted 9 lines
---
 drivers/i2c/busses/i2c-hix5hd2.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-hix5hd2.c +0 -0
index 61ae58f57047..e6ab8b20cd01 100644

drivers/i2c/busses/i2c-hix5hd2.c static int hix5hd2_i2c_xfer(struct i2c_adapter *adap, · line 371

Quoted 7 lines
drivers/i2c/busses/i2c-hix5hd2.c +3 -1
@@ -366,8 +366,17 @@ static int hix5hd2_i2c_xfer(struct i2c_adapter *adap,
 			goto out;
 	}
 
-	ret = num;
+	if (i == num) {
+		ret = num;
+	} else {

it can't be, because if you are exiting normally from the for loop, then i is equal to num.

You might want to put this inside the out label, or, even better:

stop = (i == num - 1);
ret = hix5hd2_i2c_xfer_msg(priv, msgs, stop); if (ret < 0)
- goto out;
+ break;
}

- ret = num;
+ if (i == num) {
+ ret = num;
+ } else {
+ /* Only one message, cannot access the device */
...
+ }

-out:

What do you think?

drivers/i2c/busses/i2c-hix5hd2.c static int hix5hd2_i2c_xfer(struct i2c_adapter *adap, · line 378

Quoted 7 lines
drivers/i2c/busses/i2c-hix5hd2.c +6 -0
+		/* Only one message, cannot access the device */
+		if (i == 1)
+			ret = -EREMOTEIO;
+		else
+			ret = i;
 
+		pr_warning("xfer message failed\n");

please use dev_warn here.

BTW, is it warning or error?

Andi

Quoted 7 lines
drivers/i2c/busses/i2c-hix5hd2.c +1 -0
+	}
 out:
 	pm_runtime_mark_last_busy(priv->dev);
 	pm_runtime_put_autosuspend(priv->dev);
Signature · 1 line
2.22.0