Fix parsing error for ThinkBook16 G6+ IMH.
Device: Touchpad FXTP5100
hid-generic 0018:27C6:01E9.0004: item 0 1 0 11 parsing failed
hid-generic 0018:27C6:01E9.0004: probe with driver hid-generic failed
with error -22
hid-multitouch 0018:27C6:01E9.0004: item 0 1 0 11 parsing failed
hid-multitouch 0018:27C6:01E9.0004: probe with driver hid-generic
failed with error -22
When the driver load and parsing a main item,
parser->global.logical_minimum is larger than
parser->global.logical_maximum.
parser->global.logical_minimum is 0x64 and
parser->global.logical_maximum is 0x1.
Cc: Chenzhang
Signed-off-by: Ai Chao
---
drivers/hid/hid-core.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 988d0acbdf04..cfdc4e77b846 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -271,6 +271,21 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
return -1;
}
+ /*
+ * Lenovo ThinkBook16 G6+ IMH:
+ * Touchpad FXTP5100 parsing error
+ * 0018:27C6:01E9.0004: item 0 1 0 11 parsing failed
+ */
+ if (parser->device->vendor == 0x27c6 &&
+ parser->device->product == 0x01e9 &&
+ (parser->global.logical_minimum >= 0 &&
+ (__u32)parser->global.logical_maximum global.logical_minimum)) {
+ usages = parser->global.logical_minimum;
+ parser->global.logical_minimum = parser->global.logical_maximum;
+ parser->global.logical_maximum = usages;
+ }
+
/* Handle both signed and unsigned cases properly */
if ((parser->global.logical_minimum parser->global.logical_maximum