i2c-algo-bit: Read block data bugfix
commitb73222fc44b587f1dbf08e3c47370735ef0e67f7
authorDavid Brownell <david-b@pacbell.net>
Thu, 27 Sep 2007 13:17:25 +0000 (27 15:17 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 10 Oct 2007 17:50:16 +0000 (10 10:50 -0700)
tree45e914f7b85a50aeffe9c2ad2f151473ff4455da
parentd69fedce483a75ea59fedda08aba9123adc92e80
i2c-algo-bit: Read block data bugfix

In Linus tree already:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=939bc4943d0483961edc45b63a7d27b4ffe547e3

This fixes a bug in the way i2c-algo-bit handles I2C_M_RECV_LEN,
used to implement i2c_smbus_read_block_data().  Previously, in the
absence of PEC (rarely used!) it would NAK the "length" byte:

S addr Rd [A] [length] NA

That prevents the subsequent data bytes from being read:

S addr Rd [A] [length] { A [data] }* NA

The primary fix just reorders two code blocks, so the length used
in the "should I NAK now?" check incorporates the data which it
just read from the slave device.

However, that move also highlighted other fault handling glitches.
This fixes those by abstracting the RX path ack/nak logic, so it
can be used in more than one location.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/i2c/algos/i2c-algo-bit.c