linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	freeman.liu@unisoc.com, broonie@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: sc27xx: Add ADC data conversion timeout
Date: Sun, 11 Nov 2018 12:40:44 +0000	[thread overview]
Message-ID: <20181111124044.52f61897@archlinux> (raw)
In-Reply-To: <208f9043fbd9b14b7a0c2743f68fa424388f5dcd.1541733478.git.baolin.wang@linaro.org>

On Fri,  9 Nov 2018 11:25:31 +0800
Baolin Wang <baolin.wang@linaro.org> wrote:

> From: Freeman Liu <freeman.liu@unisoc.com>
> 
> Sometimes the ADC controller met some problems, and it will not complete
> the data conversion, that will can not wake up the read process any more
> to block users. So we should add one maximum conversion time to avoid
> this issue.
> 
> Signed-off-by: Freeman Liu <freeman.liu@unisoc.com>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Hi.

Patch looks good, but sounds like this is a fix so could I have a fixes
tag and a patch title that makes that clear?

I think we will want this one back ported to stable by the sound of it.

If it is just a theoretical issue then perhaps we don't need to bother.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/sc27xx_adc.c |   12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c
> index 7940b23..f7f7a189 100644
> --- a/drivers/iio/adc/sc27xx_adc.c
> +++ b/drivers/iio/adc/sc27xx_adc.c
> @@ -52,6 +52,9 @@
>  /* Timeout (ms) for the trylock of hardware spinlocks */
>  #define SC27XX_ADC_HWLOCK_TIMEOUT	5000
>  
> +/* Timeout (ms) for ADC data conversion according to ADC datasheet */
> +#define SC27XX_ADC_RDY_TIMEOUT		100
> +
>  /* Maximum ADC channel number */
>  #define SC27XX_ADC_CHANNEL_MAX		32
>  
> @@ -223,7 +226,14 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel,
>  	if (ret)
>  		goto disable_adc;
>  
> -	wait_for_completion(&data->completion);
> +	ret = wait_for_completion_timeout(&data->completion,
> +				msecs_to_jiffies(SC27XX_ADC_RDY_TIMEOUT));
> +	if (!ret) {
> +		dev_err(data->dev, "read ADC data timeout\n");
> +		ret = -ETIMEDOUT;
> +	} else {
> +		ret = 0;
> +	}
>  
>  disable_adc:
>  	regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL,


  reply	other threads:[~2018-11-11 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09  3:25 Baolin Wang
2018-11-11 12:40 ` Jonathan Cameron [this message]
2018-11-11 15:00   ` Baolin Wang
2018-11-11 16:03     ` 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=20181111124044.52f61897@archlinux \
    --to=jic23@kernel.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=freeman.liu@unisoc.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --subject='Re: [PATCH] iio: adc: sc27xx: Add ADC data conversion timeout' \
    /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

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).