diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-09-28 05:31:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-10-01 11:19:11 -0400 |
commit | b117f96f49c92751574042136b99b8ba7eb8977f (patch) | |
tree | 198fa1cf16face08d3f8d49e0329a272778d1328 /drivers/iio/dac | |
parent | 998f129c76e2030ad2e68cf59d75eef0e5a58fd3 (diff) |
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.c | 8 |
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, | |||
239 | int *val, int *val2, long mask) | 239 | int *val, int *val2, long mask) |
240 | { | 240 | { |
241 | struct mcp4725_data *data = iio_priv(indio_dev); | 241 | struct mcp4725_data *data = iio_priv(indio_dev); |
242 | unsigned long scale_uv; | ||
243 | 242 | ||
244 | switch (mask) { | 243 | switch (mask) { |
245 | case IIO_CHAN_INFO_RAW: | 244 | case IIO_CHAN_INFO_RAW: |
246 | *val = data->dac_value; | 245 | *val = data->dac_value; |
247 | return IIO_VAL_INT; | 246 | return IIO_VAL_INT; |
248 | case IIO_CHAN_INFO_SCALE: | 247 | case IIO_CHAN_INFO_SCALE: |
249 | scale_uv = (data->vref_mv * 1000) >> 12; | 248 | *val = data->vref_mv; |
250 | *val = scale_uv / 1000000; | 249 | *val2 = 12; |
251 | *val2 = scale_uv % 1000000; | 250 | return IIO_VAL_FRACTIONAL_LOG2; |
252 | return IIO_VAL_INT_PLUS_MICRO; | ||
253 | } | 251 | } |
254 | return -EINVAL; | 252 | return -EINVAL; |
255 | } | 253 | } |