diff options
author | Thomas Andrews <tandrews@grok.co.za> | 2006-07-01 11:05:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-07-12 18:43:06 -0400 |
commit | fd627a01477dadaef3bc8556e5e9d0ef80310c3a (patch) | |
tree | 36e25979b44ad7de31e412d2b1a8fe77fca0d3ea /drivers | |
parent | 39288e1ac10b3b9a68a629be67d81a0b53512c4e (diff) |
[PATCH] scx200_acb: Fix the state machine
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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/scx200_acb.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 22a3eda04166..454086affaa1 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -184,21 +184,21 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
184 | break; | 184 | break; |
185 | 185 | ||
186 | case state_read: | 186 | case state_read: |
187 | /* Set ACK if receiving the last byte */ | 187 | /* Set ACK if _next_ byte will be the last one */ |
188 | if (iface->len == 1) | 188 | if (iface->len == 2) |
189 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); | 189 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); |
190 | else | 190 | else |
191 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); | 191 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); |
192 | 192 | ||
193 | *iface->ptr++ = inb(ACBSDA); | 193 | if (iface->len == 1) { |
194 | --iface->len; | ||
195 | |||
196 | if (iface->len == 0) { | ||
197 | iface->result = 0; | 194 | iface->result = 0; |
198 | iface->state = state_idle; | 195 | iface->state = state_idle; |
199 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | 196 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); |
200 | } | 197 | } |
201 | 198 | ||
199 | *iface->ptr++ = inb(ACBSDA); | ||
200 | --iface->len; | ||
201 | |||
202 | break; | 202 | break; |
203 | 203 | ||
204 | case state_write: | 204 | case state_write: |