iio:ad5064: Report scale as fractional value
authorLars-Peter Clausen <lars@metafoo.de>
Sat, 28 Sep 2013 09:31:00 +0000 (10:31 +0100)
committerJonathan Cameron <jic23@kernel.org>
Tue, 1 Oct 2013 15:19:08 +0000 (16:19 +0100)
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>
drivers/iio/dac/ad5064.c

index b18e8c4347c2f4476235bb70e3f166c32608b9c1..cb9c6366032cd2f8494236c52062e0b6caabdf92 100644 (file)
@@ -239,10 +239,9 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
                if (scale_uv < 0)
                        return scale_uv;
 
-               scale_uv = (scale_uv * 100) >> chan->scan_type.realbits;
-               *val =  scale_uv / 100000;
-               *val2 = (scale_uv % 100000) * 10;
-               return IIO_VAL_INT_PLUS_MICRO;
+               *val = scale_uv / 1000;
+               *val2 = chan->scan_type.realbits;
+               return IIO_VAL_FRACTIONAL_LOG2;
        default:
                break;
        }