From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752165AbcGXKJq (ORCPT ); Sun, 24 Jul 2016 06:09:46 -0400 Received: from saturn.retrosnub.co.uk ([178.18.118.26]:58412 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751870AbcGXKJn (ORCPT ); Sun, 24 Jul 2016 06:09:43 -0400 Subject: Re: [PATCH] staging: iio: ad5933: Return correct value for AD5933_OUT_RANGE. To: Phil Turnbull References: <20160721152313.16832-1-phil.turnbull@oracle.com> Cc: Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , "open list:IIO SUBSYSTEM AND DRIVERS" , "open list:STAGING SUBSYSTEM" , open list From: Jonathan Cameron Message-ID: Date: Sun, 24 Jul 2016 11:09:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160721152313.16832-1-phil.turnbull@oracle.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/07/16 16:23, Phil Turnbull wrote: > The 'break' statement after calling ad5933_cmd only breaks out of the > 'for' loop, which then unconditionally sets the return value to -EINVAL. > Move the initialisation of 'ret' so we return the correct value. > > Signed-off-by: Phil Turnbull As I have nothing in the fixes-togreg branch, I've applied this to the fixes-togreg-post-rc1 as that's the next one that will go upstream. I don't tend to send Greg fixes during the merge window as he is rather busy and won't pick them up until after anyways! This may be delayed by a few weeks though as I'm travelling. Thanks, Jonathan > --- > drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c > index 9f43976..34a6990 100644 > --- a/drivers/staging/iio/impedance-analyzer/ad5933.c > +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c > @@ -419,6 +419,7 @@ static ssize_t ad5933_store(struct device *dev, > mutex_lock(&indio_dev->mlock); > switch ((u32)this_attr->address) { > case AD5933_OUT_RANGE: > + ret = -EINVAL; > for (i = 0; i < 4; i++) > if (val == st->range_avail[i]) { > st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); > @@ -426,7 +427,6 @@ static ssize_t ad5933_store(struct device *dev, > ret = ad5933_cmd(st, 0); > break; > } > - ret = -EINVAL; > break; > case AD5933_IN_PGA_GAIN: > if (sysfs_streq(buf, "1")) { >