Skip to content

Commit

Permalink
Input: elan_i2c - fix firmware update on newer ICs
Browse files Browse the repository at this point in the history
The argument to iap page type command depends on the firmware page size.

Fixes: bfd9b92 ("Input: elan_i2c - handle firmware updated on newer ICs")
Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
jingle.wu authored and Dmitry Torokhov committed Nov 12, 2020
1 parent 676650d commit ae3d608
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/input/mouse/elan_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct elan_transport_ops {
int (*iap_reset)(struct i2c_client *client);

int (*prepare_fw_update)(struct i2c_client *client, u16 ic_type,
u8 iap_version);
u8 iap_version, u16 fw_page_size);
int (*write_fw_block)(struct i2c_client *client, u16 fw_page_size,
const u8 *page, u16 checksum, int idx);
int (*finish_fw_update)(struct i2c_client *client,
Expand Down
3 changes: 2 additions & 1 deletion drivers/input/mouse/elan_i2c_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ static int __elan_update_firmware(struct elan_tp_data *data,
u16 sw_checksum = 0, fw_checksum = 0;

error = data->ops->prepare_fw_update(client, data->ic_type,
data->iap_version);
data->iap_version,
data->fw_page_size);
if (error)
return error;

Expand Down
10 changes: 5 additions & 5 deletions drivers/input/mouse/elan_i2c_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static int elan_i2c_set_flash_key(struct i2c_client *client)
return 0;
}

static int elan_read_write_iap_type(struct i2c_client *client)
static int elan_read_write_iap_type(struct i2c_client *client, u16 fw_page_size)
{
int error;
u16 constant;
Expand All @@ -526,7 +526,7 @@ static int elan_read_write_iap_type(struct i2c_client *client)

do {
error = elan_i2c_write_cmd(client, ETP_I2C_IAP_TYPE_CMD,
ETP_I2C_IAP_TYPE_REG);
fw_page_size / 2);
if (error) {
dev_err(&client->dev,
"cannot write iap type: %d\n", error);
Expand All @@ -543,7 +543,7 @@ static int elan_read_write_iap_type(struct i2c_client *client)
constant = le16_to_cpup((__le16 *)val);
dev_dbg(&client->dev, "iap type reg: 0x%04x\n", constant);

if (constant == ETP_I2C_IAP_TYPE_REG)
if (constant == fw_page_size / 2)
return 0;

} while (--retry > 0);
Expand All @@ -553,7 +553,7 @@ static int elan_read_write_iap_type(struct i2c_client *client)
}

static int elan_i2c_prepare_fw_update(struct i2c_client *client, u16 ic_type,
u8 iap_version)
u8 iap_version, u16 fw_page_size)
{
struct device *dev = &client->dev;
int error;
Expand Down Expand Up @@ -594,7 +594,7 @@ static int elan_i2c_prepare_fw_update(struct i2c_client *client, u16 ic_type,
}

if (ic_type >= 0x0D && iap_version >= 1) {
error = elan_read_write_iap_type(client);
error = elan_read_write_iap_type(client, fw_page_size);
if (error)
return error;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/mouse/elan_i2c_smbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static int elan_smbus_set_flash_key(struct i2c_client *client)
}

static int elan_smbus_prepare_fw_update(struct i2c_client *client, u16 ic_type,
u8 iap_version)
u8 iap_version, u16 fw_page_size)
{
struct device *dev = &client->dev;
int len;
Expand Down

0 comments on commit ae3d608

Please sign in to comment.