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 4be339af33 ("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: 4be339af33 ("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>
This commit is contained in:
Uwe Kleine-König
2025-02-04 12:50:23 +01:00
committed by Jonathan Cameron
parent 5c2c07a18c
commit e903868b4c

View File

@@ -550,11 +550,10 @@ static int ad7124_disable_one(struct ad_sigma_delta *sd, unsigned int chan)
static int ad7124_disable_all(struct ad_sigma_delta *sd)
{
struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
int ret;
int i;
for (i = 0; i < st->num_channels; i++) {
for (i = 0; i < 16; i++) {
ret = ad7124_disable_one(sd, i);
if (ret < 0)
return ret;
@@ -1017,11 +1016,10 @@ static int ad7124_setup(struct ad7124_state *st)
* set all channels to this default value.
*/
ad7124_set_channel_odr(st, i, 10);
/* Disable all channels to prevent unintended conversions. */
ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0);
}
ad7124_disable_all(&st->sd);
ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);
if (ret < 0)
return dev_err_probe(dev, ret, "Failed to setup CONTROL register\n");