Skip to content

Commit fc7c882

Browse files
jinglewudtor
authored andcommitted
Input: elan_i2c - make fetching IC type of older controllers more robust
On older controllers IC type is reported in the 2nd byte of ETP_I2C_OSM_VERSION_CMD, however if controller's firmware is not flashed correctly it may return incorrect data. Fortunately there is also ETP_I2C_IAP_VERSION_P0_CMD command that can be used when controller in either normal or IAP mode, and which is guaranteed to return accurate data, so let's use it. Signed-off-by: Jingle Wu <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 77da21c commit fc7c882

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

drivers/input/mouse/elan_i2c_core.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ static int elan_initialize(struct elan_tp_data *data)
312312
static int elan_query_device_info(struct elan_tp_data *data)
313313
{
314314
int error;
315-
u16 ic_type;
316315

317316
error = data->ops->get_version(data->client, false, &data->fw_version);
318317
if (error)
@@ -336,12 +335,7 @@ static int elan_query_device_info(struct elan_tp_data *data)
336335
if (error)
337336
return error;
338337

339-
if (data->pattern == 0x01)
340-
ic_type = data->ic_type;
341-
else
342-
ic_type = data->iap_version;
343-
344-
error = elan_get_fwinfo(ic_type, &data->fw_validpage_count,
338+
error = elan_get_fwinfo(data->ic_type, &data->fw_validpage_count,
345339
&data->fw_signature_address);
346340
if (error)
347341
dev_warn(&data->client->dev,

drivers/input/mouse/elan_i2c_i2c.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#define ETP_I2C_RESOLUTION_CMD 0x0108
4444
#define ETP_I2C_PRESSURE_CMD 0x010A
4545
#define ETP_I2C_IAP_VERSION_CMD 0x0110
46+
#define ETP_I2C_IC_TYPE_P0_CMD 0x0110
4647
#define ETP_I2C_SET_CMD 0x0300
4748
#define ETP_I2C_POWER_CMD 0x0307
4849
#define ETP_I2C_FW_CHECKSUM_CMD 0x030F
@@ -330,7 +331,14 @@ static int elan_i2c_get_sm_version(struct i2c_client *client,
330331
return error;
331332
}
332333
*version = val[0];
333-
*ic_type = val[1];
334+
335+
error = elan_i2c_read_cmd(client, ETP_I2C_IC_TYPE_P0_CMD, val);
336+
if (error) {
337+
dev_err(&client->dev, "failed to get ic type: %d\n",
338+
error);
339+
return error;
340+
}
341+
*ic_type = val[0];
334342

335343
error = elan_i2c_read_cmd(client, ETP_I2C_NSM_VERSION_CMD,
336344
val);

0 commit comments

Comments
 (0)