Skip to content

Commit

Permalink
iio:ad5064: Initialize register cache correctly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Mar 2, 2013
1 parent c5ef717 commit f77ae9d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/iio/dac/ad5064.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
{
struct iio_dev *indio_dev;
struct ad5064_state *st;
unsigned int midscale;
unsigned int i;
int ret;

Expand Down Expand Up @@ -474,18 +475,20 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
goto error_free_reg;
}

for (i = 0; i < st->chip_info->num_channels; ++i) {
st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
st->dac_cache[i] = 0x8000;
}

indio_dev->dev.parent = dev;
indio_dev->name = name;
indio_dev->info = &ad5064_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels;

midscale = (1 << indio_dev->channels[0].scan_type.realbits) / 2;

for (i = 0; i < st->chip_info->num_channels; ++i) {
st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
st->dac_cache[i] = midscale;
}

ret = iio_device_register(indio_dev);
if (ret)
goto error_disable_reg;
Expand Down

0 comments on commit f77ae9d

Please sign in to comment.