Skip to content

Commit

Permalink
staging: iio: ad5933: Return correct value for AD5933_OUT_RANGE.
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Phil Turnbull authored and Jonathan Cameron committed Aug 15, 2016
1 parent bb9947c commit 776b645
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/iio/impedance-analyzer/ad5933.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ 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);
st->ctrl_hb |= AD5933_CTRL_RANGE(i);
ret = ad5933_cmd(st, 0);
break;
}
ret = -EINVAL;
break;
case AD5933_IN_PGA_GAIN:
if (sysfs_streq(buf, "1")) {
Expand Down

0 comments on commit 776b645

Please sign in to comment.