Skip to content

Commit fd09137

Browse files
Pavel BalanJiri Kosina
authored andcommitted
HID: Add quirk for incorrect input length on Lenovo Y720
Apply it to the Lenovo Y720 gaming laptop I2C peripheral then. This fixes dmesg being flooded with errors visible on un-suspend in Linux Mint 19 Cinnamon. Example of error log: <...> [ 4.326588] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.326845] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.327095] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.327341] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.327609] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) <...> Example of fixed log (debug on) <...> [ 3731.333183] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.333581] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.333842] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.334107] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.334367] i2c_hid i2c-ITE33D1:00: input: 02 00 <...> [[email protected]: rebase onto more recent codebase] Signed-off-by: Pavel Balan <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent c07a025 commit fd09137

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@
631631
#define USB_VENDOR_ID_ITE 0x048d
632632
#define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386
633633
#define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350
634+
#define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a
634635
#define USB_DEVICE_ID_ITE_LENOVO_YOGA900 0x8396
635636
#define USB_DEVICE_ID_ITE8595 0x8595
636637

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1)
5050
#define I2C_HID_QUIRK_BOGUS_IRQ BIT(4)
5151
#define I2C_HID_QUIRK_RESET_ON_RESUME BIT(5)
52+
#define I2C_HID_QUIRK_BAD_INPUT_SIZE BIT(6)
53+
5254

5355
/* flags */
5456
#define I2C_HID_STARTED 0
@@ -175,6 +177,8 @@ static const struct i2c_hid_quirks {
175177
I2C_HID_QUIRK_BOGUS_IRQ },
176178
{ USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
177179
I2C_HID_QUIRK_RESET_ON_RESUME },
180+
{ USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720,
181+
I2C_HID_QUIRK_BAD_INPUT_SIZE },
178182
{ 0, 0 }
179183
};
180184

@@ -496,9 +500,15 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
496500
}
497501

498502
if ((ret_size > size) || (ret_size < 2)) {
499-
dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
500-
__func__, size, ret_size);
501-
return;
503+
if (ihid->quirks & I2C_HID_QUIRK_BAD_INPUT_SIZE) {
504+
ihid->inbuf[0] = size & 0xff;
505+
ihid->inbuf[1] = size >> 8;
506+
ret_size = size;
507+
} else {
508+
dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
509+
__func__, size, ret_size);
510+
return;
511+
}
502512
}
503513

504514
i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf);

0 commit comments

Comments
 (0)