Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: adc: ad7124: Really disable all channels at probe time

If one or more of the 16 channels are enabled and the driver is not
aware of that, unexpected things happen because different channels are
used than intended. To prevent that, all channels should be disabled at
probe time. In Commit 4be339af334c ("iio: adc: ad7124: Disable all
channels at probe time") I intended do that, however only the channels
that are potentially used by the driver and not all channels are
disabled since then. So disable all 16 channels and not only the used
ones.

Also fix the same issue in the .disable_all() callback.

Fixes: 4be339af334c ("iio: adc: ad7124: Disable all channels at probe time")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250204115023.265813-2-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Uwe Kleine-König and committed by
Jonathan Cameron
e903868b 5c2c07a1

+3 -5
+3 -5
drivers/iio/adc/ad7124.c
··· 550 550 551 551 static int ad7124_disable_all(struct ad_sigma_delta *sd) 552 552 { 553 - struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); 554 553 int ret; 555 554 int i; 556 555 557 - for (i = 0; i < st->num_channels; i++) { 556 + for (i = 0; i < 16; i++) { 558 557 ret = ad7124_disable_one(sd, i); 559 558 if (ret < 0) 560 559 return ret; ··· 1016 1017 * set all channels to this default value. 1017 1018 */ 1018 1019 ad7124_set_channel_odr(st, i, 10); 1019 - 1020 - /* Disable all channels to prevent unintended conversions. */ 1021 - ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0); 1022 1020 } 1021 + 1022 + ad7124_disable_all(&st->sd); 1023 1023 1024 1024 ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control); 1025 1025 if (ret < 0)