aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-09-28 05:31:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-10-01 11:19:11 -0400
commit998f129c76e2030ad2e68cf59d75eef0e5a58fd3 (patch)
tree18b523c864fabd5b96fd0c5abcee1eac560c7faa
parent213983cd32a7d983675d86ece17ac040bd39fd47 (diff)
iio:max517: 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> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/dac/max517.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
index 83adcbf1a205..d26be14fff64 100644
--- a/drivers/iio/dac/max517.c
+++ b/drivers/iio/dac/max517.c
@@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
82 long m) 82 long m)
83{ 83{
84 struct max517_data *data = iio_priv(indio_dev); 84 struct max517_data *data = iio_priv(indio_dev);
85 unsigned int scale_uv;
86 85
87 switch (m) { 86 switch (m) {
88 case IIO_CHAN_INFO_SCALE: 87 case IIO_CHAN_INFO_SCALE:
89 /* Corresponds to Vref / 2^(bits) */ 88 /* Corresponds to Vref / 2^(bits) */
90 scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8; 89 *val = data->vref_mv[chan->channel];
91 *val = scale_uv / 1000000; 90 *val2 = 8;
92 *val2 = scale_uv % 1000000; 91 return IIO_VAL_FRACTIONAL_LOG2;
93 return IIO_VAL_INT_PLUS_MICRO;
94 default: 92 default:
95 break; 93 break;
96 } 94 }