staging:iio:spear_adc: 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:13 +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>
Cc: Stefan Roese <sr@denx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/spear_adc.c

index 20f2d55..657e01b 100644 (file)
@@ -168,10 +168,9 @@ static int spear_read_raw(struct iio_dev *indio_dev,
                return IIO_VAL_INT;
 
        case IIO_CHAN_INFO_SCALE:
-               scale_mv = (info->vref_external * 1000) >> DATA_BITS;
-               *val =  scale_mv / 1000;
-               *val2 = (scale_mv % 1000) * 1000;
-               return IIO_VAL_INT_PLUS_MICRO;
+               *val = info->vref_external;
+               *val2 = DATA_BITS;
+               return IIO_VAL_FRACTIONAL_LOG2;
        }
 
        return -EINVAL;