Skip to content

Commit cabd9b5

Browse files
aduggan-synaJiri Kosina
authored andcommitted
HID: rmi: The address of query8 must be calculated based on which query registers are present
If a touchpad does not report relative data then query 6 will not be present and the address of query 8 will be one less. This patches calculates the location of query 8 instead of hardcoding the offset. Signed-off-by: Andrew Duggan <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 8414947 commit cabd9b5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/hid/hid-rmi.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -632,17 +632,6 @@ static int rmi_populate_f11(struct hid_device *hdev)
632632
has_rel = !!(buf[0] & BIT(3));
633633
has_gestures = !!(buf[0] & BIT(5));
634634

635-
if (has_gestures) {
636-
/* query 8 to find out if query 10 exists */
637-
ret = rmi_read(hdev, data->f11.query_base_addr + 8, buf);
638-
if (ret) {
639-
hid_err(hdev, "can not read gesture information: %d.\n",
640-
ret);
641-
return ret;
642-
}
643-
has_query10 = !!(buf[0] & BIT(2));
644-
}
645-
646635
/*
647636
* At least 4 queries are guaranteed to be present in F11
648637
* +1 for query 5 which is present since absolute events are
@@ -653,8 +642,19 @@ static int rmi_populate_f11(struct hid_device *hdev)
653642
if (has_rel)
654643
++query_offset; /* query 6 is present */
655644

656-
if (has_gestures)
645+
if (has_gestures) {
646+
/* query 8 to find out if query 10 exists */
647+
ret = rmi_read(hdev,
648+
data->f11.query_base_addr + query_offset + 1, buf);
649+
if (ret) {
650+
hid_err(hdev, "can not read gesture information: %d.\n",
651+
ret);
652+
return ret;
653+
}
654+
has_query10 = !!(buf[0] & BIT(2));
655+
657656
query_offset += 2; /* query 7 and 8 are present */
657+
}
658658

659659
if (has_query9)
660660
++query_offset;

0 commit comments

Comments
 (0)