Skip to content

Commit ae3d608

Browse files
jinglewudtor
authored andcommitted
Input: elan_i2c - fix firmware update on newer ICs
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>
1 parent 676650d commit ae3d608

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/input/mouse/elan_i2c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct elan_transport_ops {
7878
int (*iap_reset)(struct i2c_client *client);
7979

8080
int (*prepare_fw_update)(struct i2c_client *client, u16 ic_type,
81-
u8 iap_version);
81+
u8 iap_version, u16 fw_page_size);
8282
int (*write_fw_block)(struct i2c_client *client, u16 fw_page_size,
8383
const u8 *page, u16 checksum, int idx);
8484
int (*finish_fw_update)(struct i2c_client *client,

drivers/input/mouse/elan_i2c_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ static int __elan_update_firmware(struct elan_tp_data *data,
497497
u16 sw_checksum = 0, fw_checksum = 0;
498498

499499
error = data->ops->prepare_fw_update(client, data->ic_type,
500-
data->iap_version);
500+
data->iap_version,
501+
data->fw_page_size);
501502
if (error)
502503
return error;
503504

drivers/input/mouse/elan_i2c_i2c.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ static int elan_i2c_set_flash_key(struct i2c_client *client)
517517
return 0;
518518
}
519519

520-
static int elan_read_write_iap_type(struct i2c_client *client)
520+
static int elan_read_write_iap_type(struct i2c_client *client, u16 fw_page_size)
521521
{
522522
int error;
523523
u16 constant;
@@ -526,7 +526,7 @@ static int elan_read_write_iap_type(struct i2c_client *client)
526526

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

546-
if (constant == ETP_I2C_IAP_TYPE_REG)
546+
if (constant == fw_page_size / 2)
547547
return 0;
548548

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

555555
static int elan_i2c_prepare_fw_update(struct i2c_client *client, u16 ic_type,
556-
u8 iap_version)
556+
u8 iap_version, u16 fw_page_size)
557557
{
558558
struct device *dev = &client->dev;
559559
int error;
@@ -594,7 +594,7 @@ static int elan_i2c_prepare_fw_update(struct i2c_client *client, u16 ic_type,
594594
}
595595

596596
if (ic_type >= 0x0D && iap_version >= 1) {
597-
error = elan_read_write_iap_type(client);
597+
error = elan_read_write_iap_type(client, fw_page_size);
598598
if (error)
599599
return error;
600600
}

drivers/input/mouse/elan_i2c_smbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static int elan_smbus_set_flash_key(struct i2c_client *client)
340340
}
341341

342342
static int elan_smbus_prepare_fw_update(struct i2c_client *client, u16 ic_type,
343-
u8 iap_version)
343+
u8 iap_version, u16 fw_page_size)
344344
{
345345
struct device *dev = &client->dev;
346346
int len;

0 commit comments

Comments
 (0)