Commit ffc74ad5 authored by Marcelo Schmitt's avatar Marcelo Schmitt Committed by Jonathan Cameron
Browse files

iio: adc: ad4030: Fix _scale value for common-mode channels



Previously, the driver always used the amount of precision bits of
differential input channels to provide the scale to mV. Though,
differential and common-mode voltage channels have different amount of
precision bits and the correct number of precision bits must be considered
to get to a proper mV scale factor for each one. Use channel specific
number of precision bits to provide the correct scale value for each
channel.

Fixes: de67f28a ("iio: adc: ad4030: check scan_type for error")
Fixes: 949abd1c ("iio: adc: ad4030: add averaging support")
Signed-off-by: default avatarMarcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: default avatarDavid Lechner <dlechner@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 3a866087
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ static int ad4030_get_chan_scale(struct iio_dev *indio_dev,
	struct ad4030_state *st = iio_priv(indio_dev);
	const struct iio_scan_type *scan_type;

	scan_type = iio_get_current_scan_type(indio_dev, st->chip->channels);
	scan_type = iio_get_current_scan_type(indio_dev, chan);
	if (IS_ERR(scan_type))
		return PTR_ERR(scan_type);