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

staging:iio:ad7780: 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 9324131b
...@@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, ...@@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad7780_state *st = iio_priv(indio_dev); struct ad7780_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val); return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->int_vref_mv * 100000 * st->gain) *val = st->int_vref_mv * st->gain;
>> (chan->scan_type.realbits - 1); *val2 = chan->scan_type.realbits - 1;
*val = scale_uv / 100000; return IIO_VAL_FRACTIONAL_LOG2;
*val2 = (scale_uv % 100000) * 10;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
*val -= (1 << (chan->scan_type.realbits - 1)); *val -= (1 << (chan->scan_type.realbits - 1));
return IIO_VAL_INT; return IIO_VAL_INT;
......
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