Skip to content

Commit

Permalink
staging:iio:dac:ad5446: Do not exit powerdown when writing a sample
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Greg Kroah-Hartman committed Apr 25, 2012
1 parent 0f3bcfe commit 07ffd0d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/staging/iio/dac/ad5446.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 07ffd0d

Please sign in to comment.