]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
usb: typec: tcpm: use 'time_left' variable with wait_for_completion_timeout()
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Tue, 4 Jun 2024 21:27:31 +0000 (23:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Jun 2024 17:30:10 +0000 (19:30 +0200)
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>
drivers/usb/typec/tcpm/tcpm.c

index 887c5333b9eba080c03ab2afd94fcf0269c71afd..26f9006e95e169c2dca496cfe9a13753075e4562 100644 (file)
@@ -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;
 
@@ -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) {