mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/1] usb: typec: tcpm: use 'time_left' variable with wait_for_completion_timeout()
Date: Thu, 6 Jun 2024 10:19:49 +0300	[thread overview]
Message-ID: <ZmFjFSzZwE8Z97yZ@kuha.fi.intel.com> (raw)
In-Reply-To: <20240604212730.4968-2-wsa+renesas@sang-engineering.com>

On Tue, Jun 04, 2024 at 11:27:31PM +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: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 8a1af08f71b6..e46148c19be3 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -943,7 +943,7 @@ static int tcpm_pd_transmit(struct tcpm_port *port,
>  			    enum tcpm_transmit_type tx_sop_type,
>  			    const struct pd_message *msg)
>  {
> -	unsigned long timeout;
> +	unsigned long time_left;
>  	int ret;
>  	unsigned int negotiated_rev;
>  
> @@ -968,10 +968,10 @@ static int tcpm_pd_transmit(struct tcpm_port *port,
>  		return ret;
>  
>  	mutex_unlock(&port->lock);
> -	timeout = wait_for_completion_timeout(&port->tx_complete,
> -				msecs_to_jiffies(PD_T_TCPC_TX_TIMEOUT));
> +	time_left = wait_for_completion_timeout(&port->tx_complete,
> +						msecs_to_jiffies(PD_T_TCPC_TX_TIMEOUT));
>  	mutex_lock(&port->lock);
> -	if (!timeout)
> +	if (!time_left)
>  		return -ETIMEDOUT;
>  
>  	switch (port->tx_status) {
> -- 
> 2.43.0

-- 
heikki

      reply	other threads:[~2024-06-06  7:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 21:27 Wolfram Sang
2024-06-06  7:19 ` Heikki Krogerus [this message]

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=ZmFjFSzZwE8Z97yZ@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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

Powered by JetHome