linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: iio: ad5933: Return correct value for AD5933_OUT_RANGE.
@ 2016-07-21 15:23 Phil Turnbull
  2016-07-24 10:09 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Turnbull @ 2016-07-21 15:23 UTC (permalink / raw)
  Cc: Phil Turnbull, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	Greg Kroah-Hartman, open list:IIO SUBSYSTEM AND DRIVERS,
	open list:STAGING SUBSYSTEM, open list

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 <phil.turnbull@oracle.com>
---
 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")) {
-- 
2.9.0.rc2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: iio: ad5933: Return correct value for AD5933_OUT_RANGE.
  2016-07-21 15:23 [PATCH] staging: iio: ad5933: Return correct value for AD5933_OUT_RANGE Phil Turnbull
@ 2016-07-24 10:09 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2016-07-24 10:09 UTC (permalink / raw)
  To: Phil Turnbull
  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

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 <phil.turnbull@oracle.com>
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")) {
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-24 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-21 15:23 [PATCH] staging: iio: ad5933: Return correct value for AD5933_OUT_RANGE Phil Turnbull
2016-07-24 10:09 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).