]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: adc: ad7124: set initial ADC mode to idle
authorDumitru Ceclan <mitrutzceclan@gmail.com>
Wed, 31 Jul 2024 12:37:25 +0000 (15:37 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 3 Aug 2024 15:05:53 +0000 (16:05 +0100)
During setup the st->adc_control is 0, which corresponds to a continuous
conversion mode. The reset value for channel 1 is to enable it. The
combined effect of these two is that the ADC will start conversions for
channel 1 without them being read.
This is not neccessarily a problem, but it is an unexpected behavior.

Set the ADC state to idle during setup to avoid this.

Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240731-ad7124-fix-v1-4-46a76aa4b9be@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7124.c

index 05fdd5e7123dd8997a0a4df2b30652b8405f607f..37aa3bdcdf4f6c84c1bbbbd8fd9632fc6814da8b 100644 (file)
@@ -896,6 +896,9 @@ static int ad7124_setup(struct ad7124_state *st)
        st->adc_control &= ~AD7124_ADC_CTRL_PWR_MSK;
        st->adc_control |= AD7124_ADC_CTRL_PWR(power_mode);
 
+       st->adc_control &= ~AD7124_ADC_CTRL_MODE_MSK;
+       st->adc_control |= AD7124_ADC_CTRL_MODE(AD_SD_MODE_IDLE);
+
        mutex_init(&st->cfgs_lock);
        INIT_KFIFO(st->live_cfgs_fifo);
        for (i = 0; i < st->num_channels; i++) {