Skip to contentSkip to conversation

patch "iio: adc: stm32-dfsdm: fix successive oversampling settings" added to staging-linus

PATCH [email protected] 1 participant 1 message May 9, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

iio: adc: stm32-dfsdm: fix successive oversampling settings

to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

Quoted 1 line

From 7531cf59bfa082769887ec70c2029838ea139f11 Mon Sep 17 00:00:00 2001

From: Fabrice Gasnier <[email protected]>
Date: Tue, 13 Mar 2018 15:23:05 +0100
Subject: 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 e2e6771c6462 ("IIO: ADC: add STM32 DFSDM sigma delta ADC support")
---
 drivers/iio/adc/stm32-dfsdm-adc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/stm32-dfsdm-adc.c +2 -1
index 01422d11753c..dc911b6fedd6 100644
@@ -144,6 +144,7 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
 	 * Leave as soon as if exact resolution if reached.
 	 * Otherwise the higher resolution below 32 bits is kept.
 	 */
+	fl->res = 0;
 	for (fosr = 1; fosr <= DFSDM_MAX_FL_OVERSAMPLING; fosr++) {
 		for (iosr = 1; iosr <= DFSDM_MAX_INT_OVERSAMPLING; iosr++) {
 			if (fast)
@@ -193,7 +194,7 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
 		}
 	}
 
-	if (!fl->fosr)
+	if (!fl->res)
 		return -EINVAL;
 
 	return 0;
Signature · 1 line
2.17.0