From: Fabrice Gasnier <fabrice.gasnier@st.com>
To: Lars-Peter Clausen <lars@metafoo.de>, <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <jic23@kernel.org>, <lee.jones@linaro.org>,
<linux@armlinux.org.uk>, <robh+dt@kernel.org>,
<mark.rutland@arm.com>, <mcoquelin.stm32@gmail.com>,
<alexandre.torgue@st.com>, <knaack.h@gmx.de>, <pmeerw@pmeerw.net>
Subject: Re: [PATCH v2 3/6] iio: adc: Add support for STM32 ADC
Date: Tue, 15 Nov 2016 14:26:03 +0100 [thread overview]
Message-ID: <954472c6-2ec8-48af-de7f-b5171eee692f@st.com> (raw)
In-Reply-To: <535ffb14-a92f-1556-a4cb-f2be0508289a@metafoo.de>
On 11/14/2016 01:11 PM, Lars-Peter Clausen wrote:
> On 11/10/2016 05:18 PM, Fabrice Gasnier wrote:
> [...]
>> + static int stm32_adc_single_conv(struct iio_dev *indio_dev,
>> + const struct iio_chan_spec *chan,
>> + int *res)
>> +{
>> + struct stm32_adc *adc = iio_priv(indio_dev);
>> + long timeout;
>> + u32 val;
>> + u16 result;
>> + int ret;
>> +
>> + reinit_completion(&adc->completion);
>> +
>> + adc->buffer = &result;
>> +
>> + /* Program chan number in regular sequence */
>> + val = stm32_adc_readl(adc, STM32F4_ADCX_SQR3);
>> + val &= ~STM32F4_SQ1_MASK;
>> + val |= chan->channel << STM32F4_SQ1_SHIFT;
>> + stm32_adc_writel(adc, STM32F4_ADCX_SQR3, val);
>> +
>> + /* Set regular sequence len (0 for 1 conversion) */
>> + stm32_adc_clr_bits(adc, STM32F4_ADCX_SQR1, STM32F4_L_MASK);
>> +
>> + /* Trigger detection disabled (conversion can be launched in SW) */
>> + stm32_adc_clr_bits(adc, STM32F4_ADCX_CR2, STM32F4_EXTEN_MASK);
>> +
>> + stm32_adc_conv_irq_enable(adc);
>> +
>> + stm32_adc_start_conv(adc);
>> +
>> + timeout = wait_for_completion_interruptible_timeout(
>> + &adc->completion, STM32_ADC_TIMEOUT);
>> + if (timeout == 0) {
>> + dev_warn(&indio_dev->dev, "Conversion timed out!\n");
> This should be dev_dbg() at most. This out of band reporting is not
> particular useful for applications as it is impossible to match the error to
> the action that triggered it. And you also report the error through the
> error code, so the applications knows what is going on.
>
>> + ret = -ETIMEDOUT;
>> + } else if (timeout < 0) {
>> + dev_warn(&indio_dev->dev, "Interrupted conversion!\n");
>> + ret = -EINTR;
> This should just propagate the error returned by wait_for_completion...().
> This will make sure that the right behavior occurs based on the SA_RESTART
> policy.
Hi Lars,
Thanks for reviewing.
I'll update this in next revision.
Regards,
Fabrice
>
>> + } else {
>> + *res = result;
>> + ret = IIO_VAL_INT;
>> + }
>> +
>> + stm32_adc_stop_conv(adc);
>> +
>> + stm32_adc_conv_irq_disable(adc);
>> +
>> + return ret;
next prev parent reply other threads:[~2016-11-15 13:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-10 16:18 [PATCH v2 0/6] " Fabrice Gasnier
2016-11-10 16:18 ` [PATCH v2 1/6] Documentation: dt-bindings: Document STM32 ADC DT bindings Fabrice Gasnier
2016-11-13 11:38 ` Jonathan Cameron
2016-11-10 16:18 ` [PATCH v2 2/6] mfd: stm32-adc: Add support for stm32 ADC Fabrice Gasnier
2016-11-10 21:23 ` kbuild test robot
2016-11-11 8:42 ` Lee Jones
2016-11-12 17:08 ` Jonathan Cameron
2016-11-14 16:47 ` Lee Jones
2016-11-15 10:47 ` Fabrice Gasnier
2016-11-15 13:17 ` Jonathan Cameron
2016-11-10 16:18 ` [PATCH v2 3/6] iio: adc: Add support for STM32 ADC Fabrice Gasnier
2016-11-12 17:08 ` Jonathan Cameron
2016-11-15 13:24 ` Fabrice Gasnier
2016-11-14 12:11 ` Lars-Peter Clausen
2016-11-15 13:26 ` Fabrice Gasnier [this message]
2016-11-10 16:18 ` [PATCH v2 4/6] ARM: configs: stm32: enable ADC driver Fabrice Gasnier
2016-11-10 16:18 ` [PATCH v2 5/6] ARM: dts: stm32f429: Add adc support Fabrice Gasnier
2016-11-10 16:18 ` [PATCH v2 6/6] ARM: dts: stm32f429: enable adc on eval board Fabrice Gasnier
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=954472c6-2ec8-48af-de7f-b5171eee692f@st.com \
--to=fabrice.gasnier@st.com \
--cc=alexandre.torgue@st.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@kernel.org \
/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
all inboxes | Powered by JetHome®