mfd: cros_ec: Use the proper size when looking at the cros_ec_i2c result
authorDoug Anderson <dianders@chromium.org>
Fri, 27 Jun 2014 19:56:12 +0000 (12:56 -0700)
committerLee Jones <lee.jones@linaro.org>
Wed, 9 Jul 2014 15:38:21 +0000 (16:38 +0100)
commitd6c15ed2bc703139df1c87666fb69077ad6d44d9
tree87f0f8d31aeecf78b7e6ef54dacc3f50b4837823
parent7ccf40b1a1aa060cc0c95bf00cf66f9e88636404
mfd: cros_ec: Use the proper size when looking at the cros_ec_i2c result

We know how many bytes the EC should be sending us (which is also the
number of bytes transferred) and also how many bytes the EC actually
wanted to send to us.  When computing the checksum and copying back
data let's make sure we take the lesser of the two of those.  We'll
also complain if the EC tried to send us too many bytes.  The EC
sending us too few bytes is legit for when we send the EC an invalid
command.

This is based on similar code in cros_ec_spi.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/cros_ec_i2c.c