Skip to content

Commit 7531cf5

Browse files
fgasnier63Jonathan Cameron
authored andcommitted
iio: adc: stm32-dfsdm: fix successive oversampling settings
When doing successive oversampling settings, it may fail to update filter parameters silently: - First time oversampling is being set, it will be successful, as fl->res is 0 initially. - Next attempts with various oversamp value may return 0 (success), but keep previous filter parameters, due to 'res' never reaches above or equal current 'fl->res'. This is particularly true when setting sampling frequency (that relies on oversamp). Typical failure without error: - run 1st test @16kHz samp freq will succeed - run new test @8kHZ will succeed as well - run new test @16kHz (again): sample rate will remain 8kHz without error Fixes: e2e6771 ("IIO: ADC: add STM32 DFSDM sigma delta ADC support") Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Acked-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 490fba9 commit 7531cf5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/iio/adc/stm32-dfsdm-adc.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
144144
* Leave as soon as if exact resolution if reached.
145145
* Otherwise the higher resolution below 32 bits is kept.
146146
*/
147+
fl->res = 0;
147148
for (fosr = 1; fosr <= DFSDM_MAX_FL_OVERSAMPLING; fosr++) {
148149
for (iosr = 1; iosr <= DFSDM_MAX_INT_OVERSAMPLING; iosr++) {
149150
if (fast)
@@ -193,7 +194,7 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
193194
}
194195
}
195196

196-
if (!fl->fosr)
197+
if (!fl->res)
197198
return -EINVAL;
198199

199200
return 0;

0 commit comments

Comments
 (0)