Skip to content

Commit 749de72

Browse files
Wolfram SangAndi Shyti
authored andcommitted
i2c: rk3x: use 'time_left' variable with wait_event_timeout()
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. Fix to the proper variable type 'long' while here. Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent f9288ff commit 749de72

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/i2c/busses/i2c-rk3x.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,8 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
10601060
struct i2c_msg *msgs, int num, bool polling)
10611061
{
10621062
struct rk3x_i2c *i2c = (struct rk3x_i2c *)adap->algo_data;
1063-
unsigned long timeout, flags;
1063+
unsigned long flags;
1064+
long time_left;
10641065
u32 val;
10651066
int ret = 0;
10661067
int i;
@@ -1092,20 +1093,20 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
10921093
if (!polling) {
10931094
rk3x_i2c_start(i2c);
10941095

1095-
timeout = wait_event_timeout(i2c->wait, !i2c->busy,
1096-
msecs_to_jiffies(WAIT_TIMEOUT));
1096+
time_left = wait_event_timeout(i2c->wait, !i2c->busy,
1097+
msecs_to_jiffies(WAIT_TIMEOUT));
10971098
} else {
10981099
disable_irq(i2c->irq);
10991100
rk3x_i2c_start(i2c);
11001101

1101-
timeout = rk3x_i2c_wait_xfer_poll(i2c);
1102+
time_left = rk3x_i2c_wait_xfer_poll(i2c);
11021103

11031104
enable_irq(i2c->irq);
11041105
}
11051106

11061107
spin_lock_irqsave(&i2c->lock, flags);
11071108

1108-
if (timeout == 0) {
1109+
if (time_left == 0) {
11091110
/* Force a STOP condition without interrupt */
11101111
i2c_writel(i2c, 0, REG_IEN);
11111112
val = i2c_readl(i2c, REG_CON) & REG_CON_TUNING_MASK;

0 commit comments

Comments
 (0)