Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4454476ybl; Mon, 13 Jan 2020 14:06:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzjmhudLjvPz2Sma16PJmtKk1A0V08RFZLfAB2BjGN6p81OTqWV8aLGYXdIm0VOex84RALp X-Received: by 2002:aca:cdd5:: with SMTP id d204mr14474184oig.134.1578953197470; Mon, 13 Jan 2020 14:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578953197; cv=none; d=google.com; s=arc-20160816; b=tBjueynQrdEnsXfg21eoOXsRJ+k/hCOVU35F/wwAerWzdXOcfBvUeNZDMD6BnceGBh 4XTvep4de4l7CLqs8bCKkPKCXjBhdOpvUrl2VGTNbzuuYKDiykrCXHJV8HTuHnUFLE93 7U6KFqCDuZurd+AOnB5KNy6GiT+/Eno6QZcHXq5bzyduAWnzZkZGjgRgyLc8h/4A1K10 1zBdNix3Tr12gg8+jBy0+m2AL2ODsXjG1/NytVU7oF5UOPN1bbPh4rwpdvHfbYHGR80U /InNInC7h/FnmfYsxITzsWn8FjETfoeOsOPyTZxh9gvFjeYJmeQFO+S/483H5lanH4r8 VFUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ePGZ9t7V7BkdCapHTLegPrshvOco6xN5iiVeMZpEANg=; b=MJQEuaj62S64iEsR7LJ8jDE4MBxsyj2JGUs7M+Zewtea+8W9mIjTbajrj+o1/gr7+h ELZPXsnF9TwMb9MNqcHEP/SHtfm0GrAkMOAHbWSrLTxZ7VJRmxRmVmnIMS4ckBozCk6z PpiNtYKP2JOWgVhYWbpJZXzXbW6sgouDULe7RN3KkY3Cd2khSVcPo7/Oh1us+eO4pJdk kheuwfmotyvrrUpOAacGLx1FdesPMGMm9Lobkghn/CbEn9xmRfoULXBjbHuthBxKNr3G KxqZUIaYZkjQgQj0cwQlS3zd3tk5eu109Ub6UDe8/t4lR5abD3iled4r3Tsp1bWKG6OS rrLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pHT5bBh0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 25si6338227oix.178.2020.01.13.14.06.25; Mon, 13 Jan 2020 14:06:37 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=pHT5bBh0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbgAMWCQ (ORCPT + 99 others); Mon, 13 Jan 2020 17:02:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:34970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728769AbgAMWCP (ORCPT ); Mon, 13 Jan 2020 17:02:15 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D42022072B; Mon, 13 Jan 2020 22:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578952934; bh=OgKDay9p8f2ObZyGcicQ+gy/7tCHu46EYwzbBIFy4Bw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pHT5bBh0iez8IKcr+GlyuKn5q/SAP7pNTjWGjKMvkbXrd1UI/wSmspGEACN7yYH+I /1/yBtWWtpU2t/cc18f2m4bbAs+Isbe3BZKwPYV8SnxhrkdWXoRJX+Oftin0kAmLtO +Wkfw8ev1pXrvi9Or7YvB4Zb1BizyIiaKPqXo3EY= Date: Mon, 13 Jan 2020 22:02:08 +0000 From: Jonathan Cameron To: Olivier MOYSAN Cc: "knaack.h@gmx.de" , "lars@metafoo.de" , "pmeerw@pmeerw.net" , "mcoquelin.stm32@gmail.com" , Alexandre TORGUE , Fabrice GASNIER , "linux-iio@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Benjamin GAIGNARD Subject: Re: [PATCH v2] iio: adc: stm32-dfsdm: adapt sampling rate to oversampling ratio Message-ID: <20200113220208.6471ba42@archlinux> In-Reply-To: <9b7e2161-1a31-8d69-52f9-ae9dedc902e3@st.com> References: <20191127131008.18896-1-olivier.moysan@st.com> <9b7e2161-1a31-8d69-52f9-ae9dedc902e3@st.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 10 Jan 2020 10:06:13 +0000 Olivier MOYSAN wrote: > Hi Jonathan, all, > > Kind reminder on this patch. Thanks! Applied to the togreg branch of iio.git and pushed out of testing to give the build bots a brief period to poke at it. Sorry again for the delay Thanks, Jonathan > Regards > Olivier > > On 11/27/19 2:10 PM, Olivier Moysan wrote: > > Update sampling rate when oversampling ratio is changed > > through the IIO ABI. > > > > Signed-off-by: Olivier Moysan > > --- > > changes in version 2: > > - correct title > > --- > > drivers/iio/adc/stm32-dfsdm-adc.c | 32 ++++++++++++++++++------------- > > 1 file changed, 19 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c > > index 0339ecdd06bd..87a842507509 100644 > > --- a/drivers/iio/adc/stm32-dfsdm-adc.c > > +++ b/drivers/iio/adc/stm32-dfsdm-adc.c > > @@ -1221,14 +1221,32 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, > > unsigned int spi_freq; > > int ret = -EINVAL; > > > > + switch (ch->src) { > > + case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL: > > + spi_freq = adc->dfsdm->spi_master_freq; > > + break; > > + case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING: > > + case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING: > > + spi_freq = adc->dfsdm->spi_master_freq / 2; > > + break; > > + default: > > + spi_freq = adc->spi_freq; > > + } > > + > > switch (mask) { > > case IIO_CHAN_INFO_OVERSAMPLING_RATIO: > > ret = iio_device_claim_direct_mode(indio_dev); > > if (ret) > > return ret; > > + > > ret = stm32_dfsdm_compute_all_osrs(indio_dev, val); > > - if (!ret) > > + if (!ret) { > > + dev_dbg(&indio_dev->dev, > > + "Sampling rate changed from (%u) to (%u)\n", > > + adc->sample_freq, spi_freq / val); > > adc->oversamp = val; > > + adc->sample_freq = spi_freq / val; > > + } > > iio_device_release_direct_mode(indio_dev); > > return ret; > > > > @@ -1240,18 +1258,6 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, > > if (ret) > > return ret; > > > > - switch (ch->src) { > > - case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL: > > - spi_freq = adc->dfsdm->spi_master_freq; > > - break; > > - case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING: > > - case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING: > > - spi_freq = adc->dfsdm->spi_master_freq / 2; > > - break; > > - default: > > - spi_freq = adc->spi_freq; > > - } > > - > > ret = dfsdm_adc_set_samp_freq(indio_dev, val, spi_freq); > > iio_device_release_direct_mode(indio_dev); > > return ret;