diff options
author | Luis de Bethencourt <luisbg@osg.samsung.com> | 2016-06-01 15:25:54 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-06-11 13:37:13 -0400 |
commit | f4070a19142d5ee06f0da0cef56a0e78995f172c (patch) | |
tree | 8a4e14d0addc0c0ae15d048a60223b769a7827cf /drivers/staging | |
parent | 7e982555d89cc84b1fa23b5d54c7ffd9f7753908 (diff) |
staging: iio: ad5933: fix order of cycle conditions
Correctly handle the settling time cycles value. The else branch is an
impossible condition, > 1022 in the else branch of > 511. Flipping the order.
Based on the Table 13 at the bottom of Page 25 of the Data Sheet:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/iio/impedance-analyzer/ad5933.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 9f43976f4ef2..170ac980abcb 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c | |||
@@ -444,10 +444,10 @@ static ssize_t ad5933_store(struct device *dev, | |||
444 | st->settling_cycles = val; | 444 | st->settling_cycles = val; |
445 | 445 | ||
446 | /* 2x, 4x handling, see datasheet */ | 446 | /* 2x, 4x handling, see datasheet */ |
447 | if (val > 511) | 447 | if (val > 1022) |
448 | val = (val >> 1) | (1 << 9); | ||
449 | else if (val > 1022) | ||
450 | val = (val >> 2) | (3 << 9); | 448 | val = (val >> 2) | (3 << 9); |
449 | else if (val > 511) | ||
450 | val = (val >> 1) | (1 << 9); | ||
451 | 451 | ||
452 | dat = cpu_to_be16(val); | 452 | dat = cpu_to_be16(val); |
453 | ret = ad5933_i2c_write(st->client, | 453 | ret = ad5933_i2c_write(st->client, |