summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/dac
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-04-25 07:44:52 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-25 17:57:19 (GMT)
commit07ffd0d071153aa45205891e0e577aaba1d74d0f (patch)
tree54265606f7c3669cdadb62cf06909db4e885cd1d /drivers/staging/iio/dac
parent0f3bcfe67f175d4edf0c6ab5487fbe23b6533d4a (diff)
downloadlinux-fsl-qoriq-07ffd0d071153aa45205891e0e577aaba1d74d0f.tar.xz
staging:iio:dac:ad5446: Do not exit powerdown when writing a sample
Both the powerdown mode bits and the sample value are stored in the same register, so writing a sample while the device is powered down will clear the power down bits. To avoid this only update the cached value when the device is powered down. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> ---- v1 actually had a small bug in that it would still write to the device's register when the sample was updated while the device was powered down. This was not critical since it would send out the powerdown mode again. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/iio/dac')
-rw-r--r--drivers/staging/iio/dac/ad5446.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c
index ec6968b..de796c2 100644
--- a/drivers/staging/iio/dac/ad5446.c
+++ b/drivers/staging/iio/dac/ad5446.c
@@ -272,7 +272,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,
long mask)
{
struct ad5446_state *st = iio_priv(indio_dev);
- int ret;
+ int ret = 0;
switch (mask) {
case IIO_CHAN_INFO_RAW:
@@ -282,8 +282,10 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,
val <<= chan->scan_type.shift;
mutex_lock(&indio_dev->mlock);
st->cached_val = val;
- st->chip_info->store_sample(st, val);
- ret = spi_sync(st->spi, &st->msg);
+ if (!st->pwr_down) {
+ st->chip_info->store_sample(st, val);
+ ret = spi_sync(st->spi, &st->msg);
+ }
mutex_unlock(&indio_dev->mlock);
break;
default: