Commit f4070a19 authored by Luis de Bethencourt's avatar Luis de Bethencourt Committed by Jonathan Cameron

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.pdfSigned-off-by: default avatarLuis de Bethencourt <luisbg@osg.samsung.com>
Reviewed-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 7e982555
...@@ -444,10 +444,10 @@ static ssize_t ad5933_store(struct device *dev, ...@@ -444,10 +444,10 @@ static ssize_t ad5933_store(struct device *dev,
st->settling_cycles = val; st->settling_cycles = val;
/* 2x, 4x handling, see datasheet */ /* 2x, 4x handling, see datasheet */
if (val > 511) if (val > 1022)
val = (val >> 1) | (1 << 9);
else if (val > 1022)
val = (val >> 2) | (3 << 9); val = (val >> 2) | (3 << 9);
else if (val > 511)
val = (val >> 1) | (1 << 9);
dat = cpu_to_be16(val); dat = cpu_to_be16(val);
ret = ad5933_i2c_write(st->client, ret = ad5933_i2c_write(st->client,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment