Commit b2171677 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

iio:max1363: Report scale as fractional value

Move the complexity of calculating the fixed point scale to the core.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent c45e561e
...@@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev, ...@@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
{ {
struct max1363_state *st = iio_priv(indio_dev); struct max1363_state *st = iio_priv(indio_dev);
int ret; int ret;
unsigned long scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
...@@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev, ...@@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = st->vref_uv >> st->chip_info->bits; *val = st->vref_uv / 1000;
*val = scale_uv / 1000; *val2 = st->chip_info->bits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
default: default:
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment