diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-10-19 17:47:49 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-10-19 13:57:00 -0700 |
commit | 021c0a381c5c1ae457bb9316669736d2ec66f972 (patch) | |
tree | e7849d7c6e4332c5f83354a5ba8bc8afa3b7a6a8 | |
parent | 1b992320775691ba0124bd37c5fffe16172743cd (diff) | |
download | op-kernel-dev-021c0a381c5c1ae457bb9316669736d2ec66f972.zip op-kernel-dev-021c0a381c5c1ae457bb9316669736d2ec66f972.tar.gz |
staging:iio:dac:ad5791: Use correct DAC bit-size
Commit c5b99396 ("staging:iio:dac:ad5791 chan spec conversion.") introduced a
small bug, using storagebits instead of realbits throughout the driver, which
causes the driver to work incorrectly. This patch fixes it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/iio/dac/ad5791.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index fbf446d..9a76c43 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -234,11 +234,11 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, return ret; *val &= AD5791_DAC_MASK; *val >>= chan->scan_type.shift; - *val -= (1 << (chan->scan_type.storagebits - 1)); + *val -= (1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; case (1 << IIO_CHAN_INFO_SCALE_SHARED): *val = 0; - *val2 = (st->vref_mv * 1000) >> chan->scan_type.storagebits; + *val2 = (st->vref_mv * 1000) >> chan->scan_type.realbits; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; @@ -257,8 +257,8 @@ static int ad5791_write_raw(struct iio_dev *indio_dev, switch (mask) { case 0: - val += (1 << (chan->scan_type.storagebits - 1)); - val &= AD5791_RES_MASK(chan->scan_type.storagebits); + val += (1 << (chan->scan_type.realbits - 1)); + val &= AD5791_RES_MASK(chan->scan_type.realbits); val <<= chan->scan_type.shift; return ad5791_spi_write(st->spi, chan->address, val); |