linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Baruch Siach <baruch@tkos.co.il>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-i2c@vger.kernel.org, Andi Shyti <andi.shyti@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/15] i2c: digicolor: use 'time_left' variable with wait_for_completion_timeout()
Date: Sun, 28 Apr 2024 07:38:00 +0300	[thread overview]
Message-ID: <87il02cd9a.fsf@tarshish> (raw)
In-Reply-To: <20240427203611.3750-3-wsa+renesas@sang-engineering.com>

Hi Wolfram,

On Sat, Apr 27 2024, 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>

Acked-by: Baruch Siach <baruch@tkos.co.il>

Thanks,
baruch

> ---
>  drivers/i2c/busses/i2c-digicolor.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-digicolor.c b/drivers/i2c/busses/i2c-digicolor.c
> index 3462f2bc0fa8..737604ae11fc 100644
> --- a/drivers/i2c/busses/i2c-digicolor.c
> +++ b/drivers/i2c/busses/i2c-digicolor.c
> @@ -213,7 +213,7 @@ static irqreturn_t dc_i2c_irq(int irq, void *dev_id)
>  static int dc_i2c_xfer_msg(struct dc_i2c *i2c, struct i2c_msg *msg, int first,
>  			   int last)
>  {
> -	unsigned long timeout = msecs_to_jiffies(TIMEOUT_MS);
> +	unsigned long time_left = msecs_to_jiffies(TIMEOUT_MS);
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&i2c->lock, flags);
> @@ -227,9 +227,9 @@ static int dc_i2c_xfer_msg(struct dc_i2c *i2c, struct i2c_msg *msg, int first,
>  	dc_i2c_start_msg(i2c, first);
>  	spin_unlock_irqrestore(&i2c->lock, flags);
>  
> -	timeout = wait_for_completion_timeout(&i2c->done, timeout);
> +	time_left = wait_for_completion_timeout(&i2c->done, time_left);
>  	dc_i2c_set_irq(i2c, 0);
> -	if (timeout == 0) {
> +	if (time_left == 0) {
>  		i2c->state = STATE_IDLE;
>  		return -ETIMEDOUT;
>  	}


-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-04-28  4:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-27 20:35 [PATCH 00/15] i2c: use 'time_left' with wait_for_* Wolfram Sang
2024-04-27 20:35 ` [PATCH 02/15] i2c: digicolor: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
2024-04-28  4:38   ` Baruch Siach [this message]
2024-04-27 20:35 ` [PATCH 03/15] i2c: exynos5: " Wolfram Sang
2024-04-27 20:35 ` [PATCH 05/15] i2c: imx-lpi2c: " Wolfram Sang
2024-04-28  1:45   ` Peng Fan
2024-04-27 20:35 ` [PATCH 07/15] i2c: st: " Wolfram Sang
2024-04-28 12:15   ` Uwe Kleine-König
2024-04-27 20:36 ` [PATCH 08/15] i2c: stm32f4: " Wolfram Sang
2024-04-27 20:36 ` [PATCH 09/15] i2c: stm32f7: " Wolfram Sang
2024-04-27 20:36 ` [PATCH 13/15] i2c: rk3x: use 'time_left' variable with wait_event_timeout() Wolfram Sang
2024-04-27 20:36 ` [PATCH 14/15] i2c: s3c2410: " Wolfram Sang
2024-04-30  0:07 ` [PATCH 00/15] i2c: use 'time_left' with wait_for_* Andi Shyti
2024-05-02 11:29 ` Andi Shyti

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=87il02cd9a.fsf@tarshish \
    --to=baruch@tkos.co.il \
    --cc=andi.shyti@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@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;
as well as URLs for NNTP newsgroup(s).