i2c: pxa: use 'time_left' variable with wait_event_timeout()
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 27 Apr 2024 20:36:07 +0000 (22:36 +0200)
committerAndi Shyti <andi.shyti@kernel.org>
Sun, 5 May 2024 22:56:55 +0000 (00:56 +0200)
There is a confusing pattern in the kernel to use a variable named 'timeout' to
store the result of wait_event_timeout() causing patterns like:

timeout = wait_event_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>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/busses/i2c-pxa.c

index 888ca636f3f3b009ca542747ddca2119a79daa61..f495560bd99c12f0a9eb41c5bb0aa813bf99e7bb 100644 (file)
@@ -826,7 +826,7 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c)
 static int i2c_pxa_send_mastercode(struct pxa_i2c *i2c)
 {
        u32 icr;
-       long timeout;
+       long time_left;
 
        spin_lock_irq(&i2c->lock);
        i2c->highmode_enter = true;
@@ -837,12 +837,12 @@ static int i2c_pxa_send_mastercode(struct pxa_i2c *i2c)
        writel(icr, _ICR(i2c));
 
        spin_unlock_irq(&i2c->lock);
-       timeout = wait_event_timeout(i2c->wait,
-                       i2c->highmode_enter == false, HZ * 1);
+       time_left = wait_event_timeout(i2c->wait,
+                                      i2c->highmode_enter == false, HZ * 1);
 
        i2c->highmode_enter = false;
 
-       return (timeout == 0) ? I2C_RETRY : 0;
+       return (time_left == 0) ? I2C_RETRY : 0;
 }
 
 /*
@@ -1050,7 +1050,7 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
  */
 static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
 {
-       long timeout;
+       long time_left;
        int ret;
 
        /*
@@ -1095,7 +1095,7 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
        /*
         * The rest of the processing occurs in the interrupt handler.
         */
-       timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
+       time_left = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
        i2c_pxa_stop_message(i2c);
 
        /*
@@ -1103,7 +1103,7 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
         */
        ret = i2c->msg_idx;
 
-       if (!timeout && i2c->msg_num) {
+       if (!time_left && i2c->msg_num) {
                i2c_pxa_scream_blue_murder(i2c, "timeout with active message");
                i2c_recover_bus(&i2c->adap);
                ret = I2C_RETRY;