git: e5268c3d435e - main - twsi: fix handling of consecuitve write messages in transaction

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Sun, 19 Dec 2021 10:06:03 UTC
The branch main has been updated by avg:

URL: https://cgit.FreeBSD.org/src/commit/?id=e5268c3d435e0a0f0fef64e6213504dd189272f6

commit e5268c3d435e0a0f0fef64e6213504dd189272f6
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2021-12-19 09:26:40 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-12-19 10:05:52 +0000

    twsi: fix handling of consecuitve write messages in transaction
    
    Make sure to reset 'message_done' flag when jumping from a message to the
    next one within the same interrupt handler call.  This happens only when
    a write with no-stop flag message is followed by a write with no-start
    flag message.
    Without this fix the second message would be prematurely "completed"
    without waiting for an ACK (or NACK) for its first byte and without
    sending subsequent bytes (if any).
    
    Fixes:          ff1e8581 twsi: support more message combinations in transfers
    MFC after:      4 days
---
 sys/dev/iicbus/twsi/twsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/iicbus/twsi/twsi.c b/sys/dev/iicbus/twsi/twsi.c
index ab0bb3f26961..740c7e14a31f 100644
--- a/sys/dev/iicbus/twsi/twsi.c
+++ b/sys/dev/iicbus/twsi/twsi.c
@@ -563,7 +563,6 @@ twsi_intr(void *arg)
 	bool send_start;
 
 	sc = arg;
-	message_done = false;
 	send_start = false;
 
 	mtx_lock(&sc->mutex);
@@ -582,6 +581,8 @@ twsi_intr(void *arg)
 	}
 
 restart:
+	message_done = false;
+
 	switch (status) {
 	case TWSI_STATUS_START:
 	case TWSI_STATUS_RPTD_START: