linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
To: Olivier Moysan <olivier.moysan@foss.st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Paul Cercueil <paul@crapouillou.net>,
	Wan Jiabing <wanjiabing@vivo.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 2/2] iio: adc: stm32-adc: disable adc before calibration
Date: Tue, 21 Jun 2022 17:39:08 +0200	[thread overview]
Message-ID: <9504e87e-78a5-36c5-2df9-c933c70a9103@foss.st.com> (raw)
In-Reply-To: <20220620154738.801706-3-olivier.moysan@foss.st.com>

On 6/20/22 17:47, Olivier Moysan wrote:
> The calibration is launched from prepare callback.
> The ADC state when entering this function may be unknown as the
> ADC may have been left enabled by boot stage.
> One prerequisite for ADC calibration is to have ADC in disabled state.
> If the calibration is started when ADC is still enabled, the behavior is
> unpredictable, and the calibration may fail with a timeout error.
> 
> Force ADC to disabled state in stm32h7_adc_selfcalib().
> ADC enabling is ensured by stm32h7_adc_enable() call,
> before leaving prepare callback.
> 
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>

Hi Olivier,

You can add my:
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

Thanks,
Fabrice

> ---
>  drivers/iio/adc/stm32-adc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index 80e333f65ddd..3985fe972892 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -1019,6 +1019,9 @@ static int stm32h7_adc_selfcalib(struct iio_dev *indio_dev)
>  	if (adc->cal.calibrated)
>  		return true;
>  
> +	/* ADC must be disabled for calibration */
> +	stm32h7_adc_disable(indio_dev);
> +
>  	/*
>  	 * Select calibration mode:
>  	 * - Offset calibration for single ended inputs

  reply	other threads:[~2022-06-21 15:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 15:47 [PATCH 0/2] iio: adc: stm32-adc: add checks on adc state Olivier Moysan
2022-06-20 15:47 ` [PATCH 1/2] iio: adc: stm32-adc: make safe adc disable Olivier Moysan
2022-06-21 15:38   ` Fabrice Gasnier
2022-06-20 15:47 ` [PATCH 2/2] iio: adc: stm32-adc: disable adc before calibration Olivier Moysan
2022-06-21 15:39   ` Fabrice Gasnier [this message]
2022-06-25 13:28 ` [PATCH 0/2] iio: adc: stm32-adc: add checks on adc state Jonathan Cameron

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=9504e87e-78a5-36c5-2df9-c933c70a9103@foss.st.com \
    --to=fabrice.gasnier@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=jic23@kernel.org \
    --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@foss.st.com \
    --cc=paul@crapouillou.net \
    --cc=wanjiabing@vivo.com \
    /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).