Skip to content

Commit

Permalink
staging: iio: ad5933: fix order of cycle conditions
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Lars-Peter Clausen <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
luisbg authored and jic23 committed Jun 11, 2016
1 parent 7e98255 commit f4070a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/staging/iio/impedance-analyzer/ad5933.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ static ssize_t ad5933_store(struct device *dev,
st->settling_cycles = val;

/* 2x, 4x handling, see datasheet */
if (val > 511)
val = (val >> 1) | (1 << 9);
else if (val > 1022)
if (val > 1022)
val = (val >> 2) | (3 << 9);
else if (val > 511)
val = (val >> 1) | (1 << 9);

dat = cpu_to_be16(val);
ret = ad5933_i2c_write(st->client,
Expand Down

0 comments on commit f4070a1

Please sign in to comment.