Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	 linux-iio@vger.kernel.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/8] iio: adc: ad_sigma_delta: use 'time_left' variable with wait_for_completion_timeout()
Date: Mon, 29 Apr 2024 14:06:05 +0200	[thread overview]
Message-ID: <1d9cdfa05150a389433aa399b44fcbcff5bed258.camel@gmail.com> (raw)
In-Reply-To: <20240429113313.68359-2-wsa+renesas@sang-engineering.com>

On Mon, 2024-04-29 at 13:33 +0200, Wolfram Sang wrote:
> There is a confusing pattern in the kernel to use a variable named 'timeout'
> to
> store the result of wait_for_completion_timeout() causing patterns like:
> 
> 	timeout = wait_for_completion_timeout(...)
> 	if (!timeout) return -ETIMEDOUT;
> 
> with all kinds of permutations. Use 'time_left' as a variable to make the code
> self explaining.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

>  drivers/iio/adc/ad_sigma_delta.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad_sigma_delta.c
> b/drivers/iio/adc/ad_sigma_delta.c
> index a602429cdde4..40ba6506bfc1 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -206,7 +206,7 @@ int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
>  	unsigned int mode, unsigned int channel)
>  {
>  	int ret;
> -	unsigned long timeout;
> +	unsigned long time_left;
>  
>  	ret = ad_sigma_delta_set_channel(sigma_delta, channel);
>  	if (ret)
> @@ -223,8 +223,8 @@ int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
>  
>  	sigma_delta->irq_dis = false;
>  	enable_irq(sigma_delta->spi->irq);
> -	timeout = wait_for_completion_timeout(&sigma_delta->completion, 2 *
> HZ);
> -	if (timeout == 0) {
> +	time_left = wait_for_completion_timeout(&sigma_delta->completion, 2 *
> HZ);
> +	if (time_left == 0) {
>  		sigma_delta->irq_dis = true;
>  		disable_irq_nosync(sigma_delta->spi->irq);
>  		ret = -EIO;


  reply	other threads:[~2024-04-29 12:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 11:33 [PATCH 0/8] iio: use 'time_left' instead of 'timeout' with wait_for_*() functions Wolfram Sang
2024-04-29 11:33 ` [PATCH 1/8] iio: adc: ad_sigma_delta: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
2024-04-29 12:06   ` Nuno Sá [this message]
2024-04-29 11:33 ` [PATCH 2/8] iio: adc: exynos_adc: " Wolfram Sang
2024-04-29 11:33 ` [PATCH 3/8] iio: adc: fsl-imx25-gcq: use 'time_left' variable with wait_for_completion_interruptible_timeout() Wolfram Sang
2024-04-30  1:36   ` Peng Fan
2024-04-29 11:33 ` [PATCH 4/8] iio: adc: intel_mrfld_adc: " Wolfram Sang
2024-04-29 11:33 ` [PATCH 5/8] iio: adc: stm32-adc: " Wolfram Sang
2024-04-29 11:33 ` [PATCH 6/8] iio: adc: stm32-dfsdm-adc: " Wolfram Sang
2024-04-29 11:33 ` [PATCH 7/8] iio: adc: twl6030-gpadc: " Wolfram Sang
2024-04-29 11:33 ` [PATCH 8/8] iio: pressure: zpa2326: " Wolfram Sang
2024-04-29 20:06 ` [PATCH 0/8] iio: use 'time_left' instead of 'timeout' with wait_for_*() functions 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=1d9cdfa05150a389433aa399b44fcbcff5bed258.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.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