aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-03-01 08:07:00 -0500
committerJonathan Cameron <jic23@kernel.org>2013-03-02 11:29:14 -0500
commitf77ae9d8fd4b8ed984f33e996c62f2dfd9f73b37 (patch)
tree45f529914fb1397d2dc6fd9b39527741c49209bf
parentc5ef717a774b326a6708e2e14ddf9957b619d5c4 (diff)
iio:ad5064: Initialize register cache correctly
Initialize the register cache to the proper mid-scale value based on the resolution of the device. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/dac/ad5064.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index f724a54bf334..74f2d52795f6 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -438,6 +438,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
438{ 438{
439 struct iio_dev *indio_dev; 439 struct iio_dev *indio_dev;
440 struct ad5064_state *st; 440 struct ad5064_state *st;
441 unsigned int midscale;
441 unsigned int i; 442 unsigned int i;
442 int ret; 443 int ret;
443 444
@@ -474,11 +475,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
474 goto error_free_reg; 475 goto error_free_reg;
475 } 476 }
476 477
477 for (i = 0; i < st->chip_info->num_channels; ++i) {
478 st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
479 st->dac_cache[i] = 0x8000;
480 }
481
482 indio_dev->dev.parent = dev; 478 indio_dev->dev.parent = dev;
483 indio_dev->name = name; 479 indio_dev->name = name;
484 indio_dev->info = &ad5064_info; 480 indio_dev->info = &ad5064_info;
@@ -486,6 +482,13 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
486 indio_dev->channels = st->chip_info->channels; 482 indio_dev->channels = st->chip_info->channels;
487 indio_dev->num_channels = st->chip_info->num_channels; 483 indio_dev->num_channels = st->chip_info->num_channels;
488 484
485 midscale = (1 << indio_dev->channels[0].scan_type.realbits) / 2;
486
487 for (i = 0; i < st->chip_info->num_channels; ++i) {
488 st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
489 st->dac_cache[i] = midscale;
490 }
491
489 ret = iio_device_register(indio_dev); 492 ret = iio_device_register(indio_dev);
490 if (ret) 493 if (ret)
491 goto error_disable_reg; 494 goto error_disable_reg;