From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from saturn.retrosnub.co.uk ([178.18.118.26]:59072 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751358AbbJYMbu (ORCPT ); Sun, 25 Oct 2015 08:31:50 -0400 Subject: Re: [PATCH 1/2] iio:ad5064: Make sure ad5064_i2c_write() returns 0 on success To: Lars-Peter Clausen , Hartmut Knaack , Peter Meerwald References: <1444752938-4680-1-git-send-email-lars@metafoo.de> <561D3008.2010902@metafoo.de> Cc: Marc Andre , linux-iio@vger.kernel.org, Michael Hennerich From: Jonathan Cameron Message-ID: <562CCBB4.9010902@kernel.org> Date: Sun, 25 Oct 2015 12:31:48 +0000 MIME-Version: 1.0 In-Reply-To: <561D3008.2010902@metafoo.de> Content-Type: text/plain; charset=windows-1252 Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org On 13/10/15 17:23, Lars-Peter Clausen wrote: > On 10/13/2015 06:15 PM, Lars-Peter Clausen wrote: >> From: Michael Hennerich >> >> 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 > > And obviously > > Signed-off-by: Lars-Peter Clausen Applied to fixes-togreg. > > Sorry for that. > >> --- >> drivers/iio/dac/ad5064.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c >> index c067e68..7e7ebf3 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, >> unsigned int addr, unsigned int val) >> { >> struct i2c_client *i2c = to_i2c_client(st->dev); >> + int ret; >> >> st->data.i2c[0] = (cmd << 4) | addr; >> put_unaligned_be16(val, &st->data.i2c[1]); >> - return i2c_master_send(i2c, st->data.i2c, 3); >> + >> + ret = i2c_master_send(i2c, st->data.i2c, 3); >> + if (ret < 0) >> + return ret; >> + >> + return 0; >> } >> >> static int ad5064_i2c_probe(struct i2c_client *i2c, >> > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >