diff options
| author | Uwe Kleine-König <u.kleine-koenig@baylibre.com> | 2025-02-04 12:50:23 +0100 |
|---|---|---|
| committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2025-02-08 15:16:30 +0000 |
| commit | e903868b4ce73d1ba3663d5e0718424946cebd99 (patch) | |
| tree | 5c63b51156ae1e23fbdc998a3cc42f28b1a7e0df /drivers | |
| parent | 5c2c07a18c7d9763bcc6e47466c6bbd40fcd61fc (diff) | |
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>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/iio/adc/ad7124.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 2fdeb3247952..6bc418d38820 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -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"); |
