Skip to content

Commit

Permalink
usb: typec: tcpm: use 'time_left' variable with wait_for_completion_t…
Browse files Browse the repository at this point in the history
…imeout()

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>
Link: https://lore.kernel.org/r/20240604212730.4968-2-wsa+renesas@sang-engineering.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Wolfram Sang authored and Greg Kroah-Hartman committed Jun 20, 2024
1 parent 58be297 commit 38935f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/usb/typec/tcpm/tcpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,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;

Expand All @@ -969,10 +969,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) {
Expand Down

0 comments on commit 38935f3

Please sign in to comment.