mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 19:00:25 +00:00
Input: elan_i2c - return error code when resume fails
In order to better diagnose potential issues let's return error to the upper layers when resuming the device fails and also add a few diagnostic messages. Signed-off-by: Duson Lin <dusonlin@emc.com.tw> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
ceb5b6c8be
commit
b3beed7fe8
2 changed files with 18 additions and 6 deletions
|
@ -99,7 +99,7 @@ static int elan_enable_power(struct elan_tp_data *data)
|
|||
error = regulator_enable(data->vcc);
|
||||
if (error) {
|
||||
dev_err(&data->client->dev,
|
||||
"Failed to enable regulator: %d\n", error);
|
||||
"failed to enable regulator: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,7 @@ static int elan_enable_power(struct elan_tp_data *data)
|
|||
msleep(30);
|
||||
} while (--repeat > 0);
|
||||
|
||||
dev_err(&data->client->dev, "failed to enable power: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ static int elan_disable_power(struct elan_tp_data *data)
|
|||
error = regulator_disable(data->vcc);
|
||||
if (error) {
|
||||
dev_err(&data->client->dev,
|
||||
"Failed to disable regulator: %d\n",
|
||||
"failed to disable regulator: %d\n",
|
||||
error);
|
||||
/* Attempt to power the chip back up */
|
||||
data->ops->power_control(data->client, true);
|
||||
|
@ -138,6 +139,7 @@ static int elan_disable_power(struct elan_tp_data *data)
|
|||
msleep(30);
|
||||
} while (--repeat > 0);
|
||||
|
||||
dev_err(&data->client->dev, "failed to disable power: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -1084,16 +1086,18 @@ static int __maybe_unused elan_resume(struct device *dev)
|
|||
}
|
||||
|
||||
error = elan_enable_power(data);
|
||||
if (error)
|
||||
if (error) {
|
||||
dev_err(dev, "power up when resuming failed: %d\n", error);
|
||||
goto err;
|
||||
}
|
||||
|
||||
error = elan_initialize(data);
|
||||
if (error)
|
||||
dev_err(dev, "initialize when resuming failed: %d\n", error);
|
||||
|
||||
err:
|
||||
enable_irq(data->client->irq);
|
||||
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(elan_pm_ops, elan_suspend, elan_resume);
|
||||
|
|
|
@ -117,7 +117,15 @@ static int elan_i2c_write_cmd(struct i2c_client *client, u16 reg, u16 cmd)
|
|||
int ret;
|
||||
|
||||
ret = i2c_transfer(client->adapter, &msg, 1);
|
||||
return ret == 1 ? 0 : (ret < 0 ? ret : -EIO);
|
||||
if (ret != 1) {
|
||||
if (ret >= 0)
|
||||
ret = -EIO;
|
||||
dev_err(&client->dev, "writing cmd (0x%04x) failed: %d\n",
|
||||
reg, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_initialize(struct i2c_client *client)
|
||||
|
|
Loading…
Reference in a new issue