Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755642AbbBFMCi (ORCPT ); Fri, 6 Feb 2015 07:02:38 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:41178 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755547AbbBFMCd (ORCPT ); Fri, 6 Feb 2015 07:02:33 -0500 From: Luis Henriques To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Andrew Duggan , Jiri Kosina , Joseph Salisbury , Luis Henriques Subject: [PATCH 3.16.y-ckt 072/135] HID: rmi: make compututation of the address of Query 12 more careful Date: Fri, 6 Feb 2015 12:00:50 +0000 Message-Id: <1423224113-10958-73-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423224113-10958-1-git-send-email-luis.henriques@canonical.com> References: <1423224113-10958-1-git-send-email-luis.henriques@canonical.com> X-Extended-Stable: 3.16 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2833 Lines: 91 3.16.7-ckt6 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrew Duggan commit 9e2c327ee85e37264a1e04109efc7b97844afd0b upstream. There are additional queries which are optional and may not be present depending on the configuration of the firmware. Knowing which queries are present is needed to properly compute the address of Query 12 and all subsequent queries. Additional bits in Query 1 are used to indicate the presence of these optional queries. Signed-off-by: Andrew Duggan Reviewed-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Cc: Joseph Salisbury Signed-off-by: Luis Henriques --- drivers/hid/hid-rmi.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 54966ca9e503..c8fe565667ca 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -581,10 +581,12 @@ static int rmi_populate_f11(struct hid_device *hdev) u8 buf[20]; int ret; bool has_query9; - bool has_query10; + bool has_query10 = false; bool has_query11; bool has_query12; bool has_physical_props; + bool has_gestures; + bool has_rel; unsigned x_size, y_size; u16 query12_offset; @@ -621,19 +623,32 @@ static int rmi_populate_f11(struct hid_device *hdev) return -ENODEV; } - /* query 8 to find out if query 10 exists */ - ret = rmi_read(hdev, data->f11.query_base_addr + 8, buf); - if (ret) { - hid_err(hdev, "can not read gesture information: %d.\n", ret); - return ret; + has_rel = !!(buf[0] & BIT(3)); + has_gestures = !!(buf[0] & BIT(5)); + + if (has_gestures) { + /* query 8 to find out if query 10 exists */ + ret = rmi_read(hdev, data->f11.query_base_addr + 8, buf); + if (ret) { + hid_err(hdev, "can not read gesture information: %d.\n", + ret); + return ret; + } + has_query10 = !!(buf[0] & BIT(2)); } - has_query10 = !!(buf[0] & BIT(2)); /* - * At least 8 queries are guaranteed to be present in F11 - * +1 for query12. + * At least 4 queries are guaranteed to be present in F11 + * +1 for query 5 which is present since absolute events are + * reported and +1 for query 12. */ - query12_offset = 9; + query12_offset = 6; + + if (has_rel) + ++query12_offset; /* query 6 is present */ + + if (has_gestures) + query12_offset += 2; /* query 7 and 8 are present */ if (has_query9) ++query12_offset; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/