diff options
| -rw-r--r-- | drivers/i2c/busses/i2c-img-scb.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c index 0fcc1694c607..00ffd6613680 100644 --- a/drivers/i2c/busses/i2c-img-scb.c +++ b/drivers/i2c/busses/i2c-img-scb.c | |||
| @@ -988,15 +988,16 @@ out: | |||
| 988 | static int img_i2c_reset_bus(struct img_i2c *i2c) | 988 | static int img_i2c_reset_bus(struct img_i2c *i2c) |
| 989 | { | 989 | { |
| 990 | unsigned long flags; | 990 | unsigned long flags; |
| 991 | int ret; | 991 | unsigned long time_left; |
| 992 | 992 | ||
| 993 | spin_lock_irqsave(&i2c->lock, flags); | 993 | spin_lock_irqsave(&i2c->lock, flags); |
| 994 | reinit_completion(&i2c->msg_complete); | 994 | reinit_completion(&i2c->msg_complete); |
| 995 | img_i2c_reset_start(i2c); | 995 | img_i2c_reset_start(i2c); |
| 996 | spin_unlock_irqrestore(&i2c->lock, flags); | 996 | spin_unlock_irqrestore(&i2c->lock, flags); |
| 997 | 997 | ||
| 998 | ret = wait_for_completion_timeout(&i2c->msg_complete, IMG_I2C_TIMEOUT); | 998 | time_left = wait_for_completion_timeout(&i2c->msg_complete, |
| 999 | if (ret == 0) | 999 | IMG_I2C_TIMEOUT); |
| 1000 | if (time_left == 0) | ||
| 1000 | return -ETIMEDOUT; | 1001 | return -ETIMEDOUT; |
| 1001 | return 0; | 1002 | return 0; |
| 1002 | } | 1003 | } |
| @@ -1007,6 +1008,7 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, | |||
| 1007 | struct img_i2c *i2c = i2c_get_adapdata(adap); | 1008 | struct img_i2c *i2c = i2c_get_adapdata(adap); |
| 1008 | bool atomic = false; | 1009 | bool atomic = false; |
| 1009 | int i, ret; | 1010 | int i, ret; |
| 1011 | unsigned long time_left; | ||
| 1010 | 1012 | ||
| 1011 | if (i2c->mode == MODE_SUSPEND) { | 1013 | if (i2c->mode == MODE_SUSPEND) { |
| 1012 | WARN(1, "refusing to service transaction in suspended state\n"); | 1014 | WARN(1, "refusing to service transaction in suspended state\n"); |
| @@ -1068,11 +1070,11 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, | |||
| 1068 | img_i2c_write(i2c); | 1070 | img_i2c_write(i2c); |
| 1069 | spin_unlock_irqrestore(&i2c->lock, flags); | 1071 | spin_unlock_irqrestore(&i2c->lock, flags); |
| 1070 | 1072 | ||
| 1071 | ret = wait_for_completion_timeout(&i2c->msg_complete, | 1073 | time_left = wait_for_completion_timeout(&i2c->msg_complete, |
| 1072 | IMG_I2C_TIMEOUT); | 1074 | IMG_I2C_TIMEOUT); |
| 1073 | del_timer_sync(&i2c->check_timer); | 1075 | del_timer_sync(&i2c->check_timer); |
| 1074 | 1076 | ||
| 1075 | if (ret == 0) { | 1077 | if (time_left == 0) { |
| 1076 | dev_err(adap->dev.parent, "i2c transfer timed out\n"); | 1078 | dev_err(adap->dev.parent, "i2c transfer timed out\n"); |
| 1077 | i2c->msg_status = -ETIMEDOUT; | 1079 | i2c->msg_status = -ETIMEDOUT; |
| 1078 | break; | 1080 | break; |
