i2c: stm32f7: use 'time_left' variable with wait_for_completion_timeout()
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 27 Apr 2024 20:36:01 +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-stm32f7.c

index 01210452216b333abd64e06451524784a537bca8..cfee2d9c09de36829f9e1f2dcea9f0b0f4d28e51 100644 (file)
@@ -1789,7 +1789,7 @@ static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
        struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
        struct stm32_i2c_dma *dma = i2c_dev->dma;
        struct device *dev = i2c_dev->dev;
-       unsigned long timeout;
+       unsigned long time_left;
        int i, ret;
 
        f7_msg->addr = addr;
@@ -1809,8 +1809,8 @@ static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
        if (ret)
                goto pm_free;
 
-       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 = f7_msg->result;
        if (ret) {
                if (i2c_dev->use_dma)
@@ -1826,7 +1826,7 @@ static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
                goto pm_free;
        }
 
-       if (!timeout) {
+       if (!time_left) {
                dev_dbg(dev, "Access to slave 0x%x timed out\n", f7_msg->addr);
                if (i2c_dev->use_dma)
                        dmaengine_terminate_sync(dma->chan_using);