summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKT Liao <kt.liao@emc.com.tw>2017-05-23 13:41:47 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2017-05-25 10:11:45 -0700
commita04f144059ac09f2c3da50b5707df589044aad66 (patch)
tree69263772d3c8ea4c7d2fb0608975f4f68265d2d1
parent4b3c7dbbfff0673e8a89575414b864d8b001d3bb (diff)
downloadlinux-a04f144059ac09f2c3da50b5707df589044aad66.tar.gz
linux-a04f144059ac09f2c3da50b5707df589044aad66.tar.bz2
linux-a04f144059ac09f2c3da50b5707df589044aad66.zip
Input: elan_i2c - ignore signals when finishing updating firmware
Use wait_for_completion_timeout() instead of wait_for_completion_interruptible_timeout() to avoid stray signals ruining firmware update. Our timeout is only 300 msec so we are fine simply letting it expire in case device misbehaves. Signed-off-by: KT Liao <kt.liao@emc.com.tw> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/mouse/elan_i2c_i2c.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/input/mouse/elan_i2c_i2c.c b/drivers/input/mouse/elan_i2c_i2c.c
index 765879dcaf85..f431da07f861 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -554,7 +554,6 @@ static int elan_i2c_finish_fw_update(struct i2c_client *client,
struct completion *completion)
{
struct device *dev = &client->dev;
- long ret;
int error;
int len;
u8 buffer[ETP_I2C_REPORT_LEN];
@@ -570,23 +569,19 @@ static int elan_i2c_finish_fw_update(struct i2c_client *client,
enable_irq(client->irq);
error = elan_i2c_write_cmd(client, ETP_I2C_STAND_CMD, ETP_I2C_RESET);
- if (!error)
- ret = wait_for_completion_interruptible_timeout(completion,
- msecs_to_jiffies(300));
- disable_irq(client->irq);
-
if (error) {
dev_err(dev, "device reset failed: %d\n", error);
- return error;
- } else if (ret == 0) {
+ } else if (!wait_for_completion_timeout(completion,
+ msecs_to_jiffies(300))) {
dev_err(dev, "timeout waiting for device reset\n");
- return -ETIMEDOUT;
- } else if (ret < 0) {
- error = ret;
- dev_err(dev, "error waiting for device reset: %d\n", error);
- return error;
+ error = -ETIMEDOUT;
}
+ disable_irq(client->irq);
+
+ if (error)
+ return error;
+
len = i2c_master_recv(client, buffer, ETP_I2C_INF_LENGTH);
if (len != ETP_I2C_INF_LENGTH) {
error = len < 0 ? len : -EIO;