Received: by 10.213.65.68 with SMTP id h4csp383609imn; Tue, 13 Mar 2018 07:25:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELubrurYtEP1CNQgtyZOPnMfcEN4ldHcD73YhbIEZKps/d+YuOjP8mk3zE1bAa6RrFXm6aZp X-Received: by 2002:a17:902:128c:: with SMTP id g12-v6mr755927pla.98.1520951122900; Tue, 13 Mar 2018 07:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520951122; cv=none; d=google.com; s=arc-20160816; b=yCkNSZLjmzLxS1dFnLQVCIFYrNC0DCAK7B8p+pr7k+hP/f3VWlBCo6o0LlqD9holl6 kH2FVY/pXQi2Eu8RGkN7TOo/Gb7EOWvYJfJSk8qDtEuYWCuUzSwFH2kLLv42s7lWWo6e IB0jIwUiBftfdvdUvL5NxG1npAJWg0hivHQT/mLgRJ2SMA5EFe7lQGF9VA0pFg2nXeYk 48TYuB7PHFL0r0hpnsmLAZmm8xIb4AAoZUvM30HzeJqPBGK+FmseHRVPKxK6wFBEbsqV r2vGUOzUB/vbAHVIvkSzsWnQc0F+avOqkX80PBq9Q4ASiAbXdSioKeBEljnMeIiLXFnB 4zqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=ZagMfBpcER/059VpMNagmg6xohy2FOL7b7SvCpltfkY=; b=rPIPT8usDd0gmmDIJm8cJLxx2rJVgeptv9pTnfU/YoXNdpo99QPNO/mOj94PbTK1vk L4PqhOoCvNhTdl8ti2cKAjBKiPquQBwqovb91PLbFfdDR8Xm16OyY2jOn1ZehgiJDqSY +cezmUcAc2ekaQkRuo2+opydPSdyLOXjNUY142YiSYQKU7d+8LrWlMr14Xl4P2/STQvC xbs3S84yN24Tin1vVGZgI6fwMXDyRewlxH8wlAfRgC5lFJZLhOGqffr7T6vOO2ArJ7KK 2Qdxxtpf3+zrqB7CvlUdBFWR9K+fHM8q9KYDNrUEAk0O2iefcJBADD37ztzufOEJ+/M2 lfuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si140683pgu.110.2018.03.13.07.25.07; Tue, 13 Mar 2018 07:25:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932568AbeCMOX7 (ORCPT + 99 others); Tue, 13 Mar 2018 10:23:59 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:30155 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752279AbeCMOXz (ORCPT ); Tue, 13 Mar 2018 10:23:55 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2DEIhq6017790; Tue, 13 Mar 2018 15:23:14 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gpc5s9c0s-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 13 Mar 2018 15:23:14 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 265BF38; Tue, 13 Mar 2018 14:23:14 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E7C2B576D; Tue, 13 Mar 2018 14:23:13 +0000 (GMT) Received: from localhost (10.75.127.46) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 13 Mar 2018 15:23:13 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , Subject: [PATCH 1/2] iio: adc: stm32-dfsdm: fix successive oversampling settings Date: Tue, 13 Mar 2018 15:23:05 +0100 Message-ID: <1520950986-23116-2-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520950986-23116-1-git-send-email-fabrice.gasnier@st.com> References: <1520950986-23116-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-13_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") Signed-off-by: Fabrice Gasnier --- drivers/iio/adc/stm32-dfsdm-adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 01422d1..dc911b6 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -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; -- 1.9.1