[i2c] [PATCH 03/13] scx200_acb: Fix the state machine
Jean Delvare
khali at linux-fr.org
Sat Jul 1 17:05:12 CEST 2006
From: Thomas Andrews <tandrews at grok.co.za>
Fix the scx200_acb state machine:
* Nack was sent one byte too late on reads >= 2 bytes.
* Stop bit was set one byte too late on reads.
Signed-off-by: Jean Delvare <khali at linux-fr.org>
---
drivers/i2c/busses/scx200_acb.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- linux-2.6.17-git.orig/drivers/i2c/busses/scx200_acb.c 2006-06-21 09:38:18.000000000 +0200
+++ linux-2.6.17-git/drivers/i2c/busses/scx200_acb.c 2006-06-21 20:48:46.000000000 +0200
@@ -184,21 +184,21 @@
break;
case state_read:
- /* Set ACK if receiving the last byte */
- if (iface->len == 1)
+ /* Set ACK if _next_ byte will be the last one */
+ if (iface->len == 2)
outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
else
outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
- *iface->ptr++ = inb(ACBSDA);
- --iface->len;
-
- if (iface->len == 0) {
+ if (iface->len == 1) {
iface->result = 0;
iface->state = state_idle;
outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
}
+ *iface->ptr++ = inb(ACBSDA);
+ --iface->len;
+
break;
case state_write:
--
Jean Delvare
More information about the i2c
mailing list