Skip to content

Commit d565bac

Browse files
ukleineknunojsa
authored andcommitted
iio: adc: ad7124: Disable all channels at probe time
When during a measurement two channels are enabled, two measurements are done that are reported sequencially in the DATA register. As the code triggered by reading one of the sysfs properties expects that only one channel is enabled it only reads the first data set which might or might not belong to the intended channel. To prevent this situation disable all channels during probe. This fixes a problem in practise because the reset default for channel 0 is enabled. So all measurements before the first measurement on channel 0 (which disables channel 0 at the end) might report wrong values. Fixes: 7b8d045 ("iio: adc: ad7124: allow more than 8 channels") Reviewed-by: Nuno Sa <nuno.sa@analog.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://patch.msgid.link/20241104101905.845737-2-u.kleine-koenig@baylibre.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Origin: next-20241209~124^2~24, commit:4be339af334c283a1a1af3cb28e7e448a0aa8a7c
1 parent a0e7adc commit d565bac

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/iio/adc/ad7124.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,9 @@ static int ad7124_setup(struct ad7124_state *st)
932932
* set all channels to this default value.
933933
*/
934934
ad7124_set_channel_odr(st, i, 10);
935+
936+
/* Disable all channels to prevent unintended conversions. */
937+
ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0);
935938
}
936939

937940
return ret;

0 commit comments

Comments
 (0)