mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 17:11:46 +00:00
staging:iio:ad7780: 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:
parent
9324131b5a
commit
c0d014122d
1 changed files with 3 additions and 6 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue