summaryrefslogtreecommitdiffstats
path: root/drivers/iio/dac
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-09-28 11:31:00 +0200
committerJonathan Cameron <jic23@kernel.org>2013-10-01 17:19:11 +0200
commitb117f96f49c92751574042136b99b8ba7eb8977f (patch)
tree198fa1cf16face08d3f8d49e0329a272778d1328 /drivers/iio/dac
parentiio:max517: Report scale as fractional value (diff)
downloadlinux-b117f96f49c92751574042136b99b8ba7eb8977f.tar.xz
linux-b117f96f49c92751574042136b99b8ba7eb8977f.zip
iio:mcp4725: Report scale as fractional value
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/dac')
-rw-r--r--drivers/iio/dac/mcp4725.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 7a42d85269bb..d982752dd9c4 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask)
{
struct mcp4725_data *data = iio_priv(indio_dev);
- unsigned long scale_uv;
switch (mask) {
case IIO_CHAN_INFO_RAW:
*val = data->dac_value;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- scale_uv = (data->vref_mv * 1000) >> 12;
- *val = scale_uv / 1000000;
- *val2 = scale_uv % 1000000;
- return IIO_VAL_INT_PLUS_MICRO;
+ *val = data->vref_mv;
+ *val2 = 12;
+ return IIO_VAL_FRACTIONAL_LOG2;
}
return -EINVAL;
}