From: Lars-Peter Clausen Date: Sat, 28 Sep 2013 09:31:00 +0000 (+0100) Subject: staging:iio:ad7280a: Report scale as fractional value X-Git-Tag: MMI-PSA29.97-13-9~13364^2~453^2~30 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6570b33a1c0620774fe693030ef9e0317dafd84;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git staging:iio:ad7280a: Report scale as fractional value Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index e7191e44a970..8209fa542a8a 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -783,7 +783,6 @@ static int ad7280_read_raw(struct iio_dev *indio_dev, long m) { struct ad7280_state *st = iio_priv(indio_dev); - unsigned int scale_uv; int ret; switch (m) { @@ -804,13 +803,12 @@ static int ad7280_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6) - scale_uv = (4000 * 1000) >> AD7280A_BITS; + *val = 4000; else - scale_uv = (5000 * 1000) >> AD7280A_BITS; + *val = 5000; - *val = scale_uv / 1000; - *val2 = (scale_uv % 1000) * 1000; - return IIO_VAL_INT_PLUS_MICRO; + *val2 = AD7280A_BITS; + return IIO_VAL_FRACTIONAL_LOG2; } return -EINVAL; }