Commit 3d712af6 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: elan_i2c - do not constantly re-query pattern ID

We do not need to constantly re-query pattern ID, we can instead query it
once and then pass to methods that need it.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 8d73ec74
...@@ -57,8 +57,9 @@ struct elan_transport_ops { ...@@ -57,8 +57,9 @@ struct elan_transport_ops {
int (*get_baseline_data)(struct i2c_client *client, int (*get_baseline_data)(struct i2c_client *client,
bool max_baseliune, u8 *value); bool max_baseliune, u8 *value);
int (*get_version)(struct i2c_client *client, bool iap, u8 *version); int (*get_version)(struct i2c_client *client, u8 pattern, bool iap,
int (*get_sm_version)(struct i2c_client *client, u8 *version);
int (*get_sm_version)(struct i2c_client *client, u8 pattern,
u16 *ic_type, u8 *version, u8 *clickpad); u16 *ic_type, u8 *version, u8 *clickpad);
int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum); int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
int (*get_product_id)(struct i2c_client *client, u16 *id); int (*get_product_id)(struct i2c_client *client, u16 *id);
......
...@@ -236,8 +236,13 @@ static int elan_query_product(struct elan_tp_data *data) ...@@ -236,8 +236,13 @@ static int elan_query_product(struct elan_tp_data *data)
if (error) if (error)
return error; return error;
error = data->ops->get_sm_version(data->client, &data->ic_type, error = data->ops->get_pattern(data->client, &data->pattern);
&data->sm_version, &data->clickpad); if (error)
return error;
error = data->ops->get_sm_version(data->client, data->pattern,
&data->ic_type, &data->sm_version,
&data->clickpad);
if (error) if (error)
return error; return error;
...@@ -334,7 +339,8 @@ static int elan_query_device_info(struct elan_tp_data *data) ...@@ -334,7 +339,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
{ {
int error; int error;
error = data->ops->get_version(data->client, false, &data->fw_version); error = data->ops->get_version(data->client, data->pattern, false,
&data->fw_version);
if (error) if (error)
return error; return error;
...@@ -343,7 +349,8 @@ static int elan_query_device_info(struct elan_tp_data *data) ...@@ -343,7 +349,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error) if (error)
return error; return error;
error = data->ops->get_version(data->client, true, &data->iap_version); error = data->ops->get_version(data->client, data->pattern,
true, &data->iap_version);
if (error) if (error)
return error; return error;
...@@ -352,10 +359,6 @@ static int elan_query_device_info(struct elan_tp_data *data) ...@@ -352,10 +359,6 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error) if (error)
return error; return error;
error = data->ops->get_pattern(data->client, &data->pattern);
if (error)
return error;
error = elan_get_fwinfo(data->ic_type, data->iap_version, error = elan_get_fwinfo(data->ic_type, data->iap_version,
&data->fw_validpage_count, &data->fw_validpage_count,
&data->fw_signature_address, &data->fw_signature_address,
......
...@@ -266,22 +266,15 @@ static int elan_i2c_get_pattern(struct i2c_client *client, u8 *pattern) ...@@ -266,22 +266,15 @@ static int elan_i2c_get_pattern(struct i2c_client *client, u8 *pattern)
} }
static int elan_i2c_get_version(struct i2c_client *client, static int elan_i2c_get_version(struct i2c_client *client,
bool iap, u8 *version) u8 pattern, bool iap, u8 *version)
{ {
int error; int error;
u8 pattern_ver;
u16 cmd; u16 cmd;
u8 val[3]; u8 val[3];
error = elan_i2c_get_pattern(client, &pattern_ver);
if (error) {
dev_err(&client->dev, "failed to get pattern version\n");
return error;
}
if (!iap) if (!iap)
cmd = ETP_I2C_FW_VERSION_CMD; cmd = ETP_I2C_FW_VERSION_CMD;
else if (pattern_ver == 0) else if (pattern == 0)
cmd = ETP_I2C_IAP_VERSION_P0_CMD; cmd = ETP_I2C_IAP_VERSION_P0_CMD;
else else
cmd = ETP_I2C_IAP_VERSION_CMD; cmd = ETP_I2C_IAP_VERSION_CMD;
...@@ -293,28 +286,20 @@ static int elan_i2c_get_version(struct i2c_client *client, ...@@ -293,28 +286,20 @@ static int elan_i2c_get_version(struct i2c_client *client,
return error; return error;
} }
if (pattern_ver >= 0x01) if (pattern >= 0x01)
*version = iap ? val[1] : val[0]; *version = iap ? val[1] : val[0];
else else
*version = val[0]; *version = val[0];
return 0; return 0;
} }
static int elan_i2c_get_sm_version(struct i2c_client *client, static int elan_i2c_get_sm_version(struct i2c_client *client, u8 pattern,
u16 *ic_type, u8 *version, u16 *ic_type, u8 *version, u8 *clickpad)
u8 *clickpad)
{ {
int error; int error;
u8 pattern_ver;
u8 val[3]; u8 val[3];
error = elan_i2c_get_pattern(client, &pattern_ver); if (pattern >= 0x01) {
if (error) {
dev_err(&client->dev, "failed to get pattern version\n");
return error;
}
if (pattern_ver >= 0x01) {
error = elan_i2c_read_cmd(client, ETP_I2C_IC_TYPE_CMD, val); error = elan_i2c_read_cmd(client, ETP_I2C_IC_TYPE_CMD, val);
if (error) { if (error) {
dev_err(&client->dev, "failed to get ic type: %d\n", dev_err(&client->dev, "failed to get ic type: %d\n",
......
...@@ -147,7 +147,7 @@ static int elan_smbus_get_baseline_data(struct i2c_client *client, ...@@ -147,7 +147,7 @@ static int elan_smbus_get_baseline_data(struct i2c_client *client,
} }
static int elan_smbus_get_version(struct i2c_client *client, static int elan_smbus_get_version(struct i2c_client *client,
bool iap, u8 *version) u8 pattern, bool iap, u8 *version)
{ {
int error; int error;
u8 val[I2C_SMBUS_BLOCK_MAX] = {0}; u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
...@@ -166,9 +166,8 @@ static int elan_smbus_get_version(struct i2c_client *client, ...@@ -166,9 +166,8 @@ static int elan_smbus_get_version(struct i2c_client *client,
return 0; return 0;
} }
static int elan_smbus_get_sm_version(struct i2c_client *client, static int elan_smbus_get_sm_version(struct i2c_client *client, u8 pattern,
u16 *ic_type, u8 *version, u16 *ic_type, u8 *version, u8 *clickpad)
u8 *clickpad)
{ {
int error; int error;
u8 val[I2C_SMBUS_BLOCK_MAX] = {0}; u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment