summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Andrews <tandrews@grok.co.za>2006-11-11 00:09:25 +0100
committerAdrian Bunk <bunk@stusta.de>2006-11-11 00:09:25 +0100
commitb88acf65abec97a9b44c42d921c930c4d62d7b5e (patch)
tree7d159aee505fbd42e3ef07aa700e6dc964f79df2
parentb235e2832575ccde51f00eda1cade521a0f193fd (diff)
downloadlwn-b88acf65abec97a9b44c42d921c930c4d62d7b5e.tar.gz
lwn-b88acf65abec97a9b44c42d921c930c4d62d7b5e.zip
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@linux-fr.org> Signed-off-by: Adrian Bunk <bunk@stusta.de>
-rw-r--r--drivers/i2c/busses/scx200_acb.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index ad44dd5359ae..e28fb6973e5e 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -178,21 +178,21 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
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: