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

iio:mcp4725: 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>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 998f129c
...@@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev, ...@@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
struct mcp4725_data *data = iio_priv(indio_dev); struct mcp4725_data *data = iio_priv(indio_dev);
unsigned long scale_uv;
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
*val = data->dac_value; *val = data->dac_value;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (data->vref_mv * 1000) >> 12; *val = data->vref_mv;
*val = scale_uv / 1000000; *val2 = 12;
*val2 = scale_uv % 1000000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
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