diff mbox series

[v2,2/2] i2c: viai2c: Fix bug for msg->len is 0

Message ID 3fb1398741536232a1e9b54a5de4072420046db5.1710146668.git.hanshu-oc@zhaoxin.com
State New
Headers show
Series [v2,1/2] i2c: viai2c: Fix some minor style issues | expand

Commit Message

Hans Hu March 11, 2024, 8:46 a.m. UTC
For the case that msg->len is 0(I2C_SMBUS_QUICK), when the interrupt
occurs, it means that the access has completed, viai2c_irq_xfer()
should return 1.

v1->v2:
	Added some code comments; The commit log is adjusted.
	Link: https://lore.kernel.org/all/20240311032600.56244-2-hanshu-oc@zhaoxin.com/

Signed-off-by: Hans Hu <hanshu-oc@zhaoxin.com>
---
 drivers/i2c/busses/i2c-viai2c-common.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Hans Hu March 11, 2024, 10:51 a.m. UTC | #1
Hi Andi,


On 2024/3/11 17:46, Andi Shyti wrote:
>
> [这封邮件来自外部发件人 谨防风险]
>
> Hi Hans,
>
> because Mukes had questions on the v1, please do include him for
> the next versions.
>
> On Mon, Mar 11, 2024 at 04:46:55PM +0800, Hans Hu wrote:
>> For the case that msg->len is 0(I2C_SMBUS_QUICK), when the interrupt
>> occurs, it means that the access has completed, viai2c_irq_xfer()
>> should return 1.
> The commit log is still not enough. We don't konw which patch has
> introduced the error and why.
>
> Next time, please, try to be a bit more specific, trying to anser
> the questions:
>
>   - what is the problem
>   - how did you find out
>   - how you fixed
>   - how you tested it
>
> But, I see that the issue was introduced here:
>
>    4b0c0569f032 ("i2c: wmt: fix a bug when thread blocked")
>
> This patch has not been yet merged into Wolfram's tree.
> Therefore, I will ask you to let this go this time and we can
> take the whole series after the merge window.
>
> Please, fix all the issues you find, including the checkpatch
> warnings/errors (please keep one patch per kind of checkpatch
> fix).
>
> Last thing, please keep bug fixes separate from
> features/cosmetic/refactoring. They need to be merged separately.
>
> Does it work for you?

No other issues have been found so far.

All these suggestions you mentioned, I will pay attention to when
submitting patches in the future.


Hans,
Thanks
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-viai2c-common.c b/drivers/i2c/busses/i2c-viai2c-common.c
index 4c208b3a509e..fbb76d7ea3b0 100644
--- a/drivers/i2c/busses/i2c-viai2c-common.c
+++ b/drivers/i2c/busses/i2c-viai2c-common.c
@@ -123,6 +123,14 @@  int viai2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 	return (ret < 0) ? ret : i;
 }
 
+/*
+ * Main process of the byte mode xfer
+ *
+ * Return value indicates whether the transfer is complete
+ *  1: all the data has been successfully transferred
+ *  0: there is still data that needs to be transferred
+ *  -EIO: error occurred
+ */
 static int viai2c_irq_xfer(struct viai2c *i2c)
 {
 	u16 val;
@@ -142,10 +150,11 @@  static int viai2c_irq_xfer(struct viai2c *i2c)
 		if (val & VIAI2C_CSR_RCV_NOT_ACK)
 			return -EIO;
 
+		/* I2C_SMBUS_QUICK */
 		if (msg->len == 0) {
 			val = VIAI2C_CR_TX_END | VIAI2C_CR_CPU_RDY | VIAI2C_CR_ENABLE;
 			writew(val, base + VIAI2C_REG_CR);
-			return 0;
+			return 1;
 		}
 
 		if ((i2c->xfered_len + 1) == msg->len) {
@@ -195,6 +204,7 @@  static irqreturn_t viai2c_isr(int irq, void *data)
 			i2c->ret = viai2c_fifo_irq_xfer(i2c, true);
 	}
 
+	/* All the data has been successfully transferred or error occurred */
 	if (i2c->ret)
 		complete(&i2c->complete);