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>
This commit is contained in:
Lars-Peter Clausen 2013-09-28 10:31:00 +01:00 committed by Jonathan Cameron
parent 213983cd32
commit 998f129c76

View File

@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct max517_data *data = iio_priv(indio_dev); struct max517_data *data = iio_priv(indio_dev);
unsigned int scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
/* Corresponds to Vref / 2^(bits) */ /* Corresponds to Vref / 2^(bits) */
scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8; *val = data->vref_mv[chan->channel];
*val = scale_uv / 1000000; *val2 = 8;
*val2 = scale_uv % 1000000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
default: default:
break; break;
} }