Skip to content

Commit 03fe472

Browse files
mhennerichjic23
authored andcommitted
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 6a17a07 ("iio:dac:ad5064: Add support for the ad5629r and ad5669r") Signed-off-by: Michael Hennerich <[email protected]> Signed-off-by: Lars-Peter Clausen <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 01bb70a commit 03fe472

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/iio/dac/ad5064.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,16 @@ static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
598598
unsigned int addr, unsigned int val)
599599
{
600600
struct i2c_client *i2c = to_i2c_client(st->dev);
601+
int ret;
601602

602603
st->data.i2c[0] = (cmd << 4) | addr;
603604
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;
605611
}
606612

607613
static int ad5064_i2c_probe(struct i2c_client *i2c,

0 commit comments

Comments
 (0)