lkml.org 
[lkml]   [2024]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 09/15] i2c: stm32f7: use 'time_left' variable with wait_for_completion_timeout()
    Date
    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>
    ---
    drivers/i2c/busses/i2c-stm32f7.c | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)

    diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
    index 01210452216b..cfee2d9c09de 100644
    --- a/drivers/i2c/busses/i2c-stm32f7.c
    +++ b/drivers/i2c/busses/i2c-stm32f7.c
    @@ -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);
    --
    2.43.0

    \
     
     \ /
      Last update: 2024-05-27 18:06    [W:4.623 / U:0.132 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site