Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 998f129c authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron
Browse files

iio:max517: 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 213983cd
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
			   long m)
{
	struct max517_data *data = iio_priv(indio_dev);
	unsigned int scale_uv;

	switch (m) {
	case IIO_CHAN_INFO_SCALE:
		/* Corresponds to Vref / 2^(bits) */
		scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8;
		*val =  scale_uv / 1000000;
		*val2 = scale_uv % 1000000;
		return IIO_VAL_INT_PLUS_MICRO;
		*val = data->vref_mv[chan->channel];
		*val2 = 8;
		return IIO_VAL_FRACTIONAL_LOG2;
	default:
		break;
	}