From: Jonathan Cameron <jic23@kernel.org>
To: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <mcoquelin.stm32@gmail.com>,
<alexandre.torgue@st.com>, <linux-iio@vger.kernel.org>,
<lars@metafoo.de>, <knaack.h@gmx.de>, <pmeerw@pmeerw.net>,
<linux-stm32@st-md-mailman.stormreply.com>,
<arnaud.pouliquen@st.com>, <olivier.moysan@st.com>
Subject: Re: [PATCH v2 8/8] iio: adc: stm32-dfsdm: claim direct mode for raw read and settings
Date: Sun, 24 Mar 2019 17:12:42 +0000 [thread overview]
Message-ID: <20190324171242.67d7a486@archlinux> (raw)
In-Reply-To: <1553186849-6261-9-git-send-email-fabrice.gasnier@st.com>
On Thu, 21 Mar 2019 17:47:29 +0100
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:
> Claim direct mode to ensure no buffer mode is in use for:
> - single conversion
> - sample rate setting (must be set when filter isn't enabled).
> - oversampling ratio (must be set when filter isn't enabled).
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/adc/stm32-dfsdm-adc.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
> index 51688eb..ca42946 100644
> --- a/drivers/iio/adc/stm32-dfsdm-adc.c
> +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
> @@ -1039,16 +1039,23 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
>
> switch (mask) {
> case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> + ret = iio_device_claim_direct_mode(indio_dev);
> + if (ret)
> + return ret;
> ret = stm32_dfsdm_set_osrs(fl, 0, val);
> if (!ret)
> adc->oversamp = val;
> -
> + iio_device_release_direct_mode(indio_dev);
> return ret;
>
> case IIO_CHAN_INFO_SAMP_FREQ:
> if (!val)
> return -EINVAL;
>
> + ret = iio_device_claim_direct_mode(indio_dev);
> + if (ret)
> + return ret;
> +
> switch (ch->src) {
> case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL:
> spi_freq = adc->dfsdm->spi_master_freq;
> @@ -1070,9 +1077,11 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
> if (ret < 0) {
> dev_err(&indio_dev->dev,
> "Not able to find parameter that match!\n");
> + iio_device_release_direct_mode(indio_dev);
> return ret;
> }
> adc->sample_freq = val;
> + iio_device_release_direct_mode(indio_dev);
>
> return 0;
> }
> @@ -1089,11 +1098,15 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev,
>
> switch (mask) {
> case IIO_CHAN_INFO_RAW:
> + ret = iio_device_claim_direct_mode(indio_dev);
> + if (ret)
> + return ret;
> ret = iio_hw_consumer_enable(adc->hwc);
> if (ret < 0) {
> dev_err(&indio_dev->dev,
> "%s: IIO enable failed (channel %d)\n",
> __func__, chan->channel);
> + iio_device_release_direct_mode(indio_dev);
> return ret;
> }
> ret = stm32_dfsdm_single_conv(indio_dev, chan, val);
> @@ -1102,8 +1115,10 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev,
> dev_err(&indio_dev->dev,
> "%s: Conversion failed (channel %d)\n",
> __func__, chan->channel);
> + iio_device_release_direct_mode(indio_dev);
> return ret;
> }
> + iio_device_release_direct_mode(indio_dev);
> return IIO_VAL_INT;
>
> case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
prev parent reply other threads:[~2019-03-24 17:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 16:47 [PATCH v2 0/8] iio: adc: stm32-dfsdm: add buffer modes Fabrice Gasnier
2019-03-21 16:47 ` [PATCH v2 1/8] iio: adc: stm32-dfsdm: make spi_master_freq more accurate Fabrice Gasnier
2019-03-24 16:41 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 2/8] iio: adc: stm32-dfsdm: continuous mode depends on current mode Fabrice Gasnier
2019-03-24 16:43 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 3/8] iio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma() Fabrice Gasnier
2019-03-24 16:44 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Fabrice Gasnier
2019-03-24 16:45 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 5/8] iio: adc: stm32-dfsdm: enable hw consumer Fabrice Gasnier
2019-03-24 16:45 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 6/8] iio: adc: stm32-dfsdm: add support for scan mode Fabrice Gasnier
2019-03-24 16:46 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 7/8] iio: adc: stm32-dfsdm: add support for buffer modes Fabrice Gasnier
2019-03-24 17:11 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 8/8] iio: adc: stm32-dfsdm: claim direct mode for raw read and settings Fabrice Gasnier
2019-03-24 17:12 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190324171242.67d7a486@archlinux \
--to=jic23@kernel.org \
--cc=alexandre.torgue@st.com \
--cc=arnaud.pouliquen@st.com \
--cc=fabrice.gasnier@st.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=olivier.moysan@st.com \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).