Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 3/8] iio: adc: fsl-imx25-gcq: use 'time_left' variable with wait_for_completion_interruptible_timeout()
Date: Tue, 30 Apr 2024 01:36:14 +0000	[thread overview]
Message-ID: <DU0PR04MB9417CE73856B1E1B1CC3D62C881A2@DU0PR04MB9417.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20240429113313.68359-4-wsa+renesas@sang-engineering.com>

> Subject: [PATCH 3/8] iio: adc: fsl-imx25-gcq: use 'time_left' variable with
> wait_for_completion_interruptible_timeout()
> 
> There is a confusing pattern in the kernel to use a variable named 'timeout' to
> store the result of wait_for_completion_interruptible_timeout() causing
> patterns like:
> 
> 	timeout = wait_for_completion_interruptible_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: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/iio/adc/fsl-imx25-gcq.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c
> index 68c813de0605..dabc5303d644 100644
> --- a/drivers/iio/adc/fsl-imx25-gcq.c
> +++ b/drivers/iio/adc/fsl-imx25-gcq.c
> @@ -107,7 +107,7 @@ static int mx25_gcq_get_raw_value(struct device
> *dev,
>  				  struct mx25_gcq_priv *priv,
>  				  int *val)
>  {
> -	long timeout;
> +	long time_left;
>  	u32 data;
> 
>  	/* Setup the configuration we want to use */ @@ -120,12 +120,12
> @@ static int mx25_gcq_get_raw_value(struct device *dev,
>  	regmap_update_bits(priv->regs, MX25_ADCQ_CR,
> MX25_ADCQ_CR_FQS,
>  			   MX25_ADCQ_CR_FQS);
> 
> -	timeout = wait_for_completion_interruptible_timeout(
> +	time_left = wait_for_completion_interruptible_timeout(
>  		&priv->completed, MX25_GCQ_TIMEOUT);
> -	if (timeout < 0) {
> +	if (time_left < 0) {
>  		dev_err(dev, "ADC wait for measurement failed\n");
> -		return timeout;
> -	} else if (timeout == 0) {
> +		return time_left;
> +	} else if (time_left == 0) {
>  		dev_err(dev, "ADC timed out\n");
>  		return -ETIMEDOUT;
>  	}
> --
> 2.43.0
> 


  reply	other threads:[~2024-04-30  1:36 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á
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 [this message]
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=DU0PR04MB9417CE73856B1E1B1CC3D62C881A2@DU0PR04MB9417.eurprd04.prod.outlook.com \
    --to=peng.fan@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=jic23@kernel.org \
    --cc=kernel@pengutronix.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=s.hauer@pengutronix.de \
    --cc=shawnguo@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).