diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2015-10-13 12:15:37 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-10-25 08:29:31 -0400 |
commit | 03fe472ef33b7f31fbd11d300dbb3fdab9c00fd4 (patch) | |
tree | c1054df232fb8142c751036f71abd323616db9df | |
parent | 01bb70ae0b98d266fa3e860482c7ce22fa482a6e (diff) |
iio:ad5064: Make sure ad5064_i2c_write() returns 0 on success
i2c_master_send() returns the number of bytes transferred on success while
the ad5064 driver expects that the write() callback returns 0 on success.
Fix that by translating any non negative return value of i2c_master_send()
to 0.
Fixes: commit 6a17a0768f77 ("iio:dac:ad5064: Add support for the ad5629r and ad5669r")
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/dac/ad5064.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index c067e6821496..7e7ebf30e954 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c | |||
@@ -598,10 +598,16 @@ static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd, | |||
598 | unsigned int addr, unsigned int val) | 598 | unsigned int addr, unsigned int val) |
599 | { | 599 | { |
600 | struct i2c_client *i2c = to_i2c_client(st->dev); | 600 | struct i2c_client *i2c = to_i2c_client(st->dev); |
601 | int ret; | ||
601 | 602 | ||
602 | st->data.i2c[0] = (cmd << 4) | addr; | 603 | st->data.i2c[0] = (cmd << 4) | addr; |
603 | put_unaligned_be16(val, &st->data.i2c[1]); | 604 | put_unaligned_be16(val, &st->data.i2c[1]); |
604 | return i2c_master_send(i2c, st->data.i2c, 3); | 605 | |
606 | ret = i2c_master_send(i2c, st->data.i2c, 3); | ||
607 | if (ret < 0) | ||
608 | return ret; | ||
609 | |||
610 | return 0; | ||
605 | } | 611 | } |
606 | 612 | ||
607 | static int ad5064_i2c_probe(struct i2c_client *i2c, | 613 | static int ad5064_i2c_probe(struct i2c_client *i2c, |