i2c: stm32f4: use 'time_left' variable with wait_for_completion_timeout()
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 27 Apr 2024 20:36:00 +0000 (22:36 +0200)
committerAndi Shyti <andi.shyti@kernel.org>
Sun, 5 May 2024 22:56:52 +0000 (00:56 +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>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/busses/i2c-stm32f4.c

index 859ac0cf7f6cb156a5bde7a5ad81be6440f5eed9..f8b12be6ef55b02fa0b8dad3292e53c79da1e0a2 100644 (file)
@@ -681,7 +681,7 @@ static int stm32f4_i2c_xfer_msg(struct stm32f4_i2c_dev *i2c_dev,
 {
        struct stm32f4_i2c_msg *f4_msg = &i2c_dev->msg;
        void __iomem *reg = i2c_dev->base + STM32F4_I2C_CR1;
-       unsigned long timeout;
+       unsigned long time_left;
        u32 mask;
        int ret;
 
@@ -706,11 +706,11 @@ static int stm32f4_i2c_xfer_msg(struct stm32f4_i2c_dev *i2c_dev,
                stm32f4_i2c_set_bits(reg, STM32F4_I2C_CR1_START);
        }
 
-       timeout = wait_for_completion_timeout(&i2c_dev->complete,
-                                             i2c_dev->adap.timeout);
+       time_left = wait_for_completion_timeout(&i2c_dev->complete,
+                                               i2c_dev->adap.timeout);
        ret = f4_msg->result;
 
-       if (!timeout)
+       if (!time_left)
                ret = -ETIMEDOUT;
 
        return ret;