From patchwork Mon Aug 22 16:58:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Duggan X-Patchwork-Id: 9293973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F901608A7 for ; Mon, 22 Aug 2016 17:00:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DF882898D for ; Mon, 22 Aug 2016 17:00:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22304289A5; Mon, 22 Aug 2016 17:00:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E74AB2898D for ; Mon, 22 Aug 2016 17:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932578AbcHVQ7e (ORCPT ); Mon, 22 Aug 2016 12:59:34 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:34735 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882AbcHVQ7d (ORCPT ); Mon, 22 Aug 2016 12:59:33 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 16F4720384; Mon, 22 Aug 2016 12:59:32 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Mon, 22 Aug 2016 12:59:32 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=duggan.us; h=cc :date:from:message-id:subject:to:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=g0vBk8kkiB/OuXP4wtx44KAT9/I=; b=UeLIZQ7UO0Xcu3eObIl/j 8AmUmQY71lfuZ8EnnExAAqeY5tQ5VtEC83So3jlGtvx/D31H2jOwenit9MMBj8oB WvUkjkQTYRODs3mNA2jOqFtaXV3cocMj2HVTzpX607eajJpj7o5AbBU4eV1h8Qzf unVAn4/u6vfUnznAP+fkrg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-sasl-enc:x-sasl-enc; s=smtpout; bh=g0vBk8kkiB/OuXP4wtx44KAT9/ I=; b=aSrvNfg1e3FNFBYa8WWFueyGYVieUiskgvaGYP/s1EOlXYwc15YY6HUhay +2KLEy8D5eTq33xJIiPIXi6ziy6pC20dC46z3g5aoyJQQFc5NGm1a2/EYC8G47Pp dbdWEna19+h6Jqs3hSS/ge+afG7TbushaWy4Oto9e1gb1gFVY= X-Sasl-enc: OoGr7ta6bYTORejrpHwy/Ck8HeX8XLy0wraONSub2P1/ 1471885171 Received: from noble.synaptics-inc.local (unknown [192.147.44.15]) by mail.messagingengine.com (Postfix) with ESMTPA id 013A5F2983; Mon, 22 Aug 2016 12:59:30 -0400 (EDT) From: Andrew Duggan To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Duggan , Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires , Vincent Huang , Chris Healy , Nitin Chaudhary , stable@vger.kernel.org Subject: [PATCH v2] Input: synaptics-rmi4: Fix register descriptor subpacket map construction Date: Mon, 22 Aug 2016 09:58:57 -0700 Message-Id: <1471885137-3378-1-git-send-email-andrew@duggan.us> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Duggan The map_offset variable is specific to the register and needs to be reset in the loop. Otherwise, subsequent register's subpacket maps will have their bits set at the wrong index. Signed-off-by: Andrew Duggan Tested-by: Nitin Chaudhary Reviewed-by: Benjamin Tissoires Cc: stable@vger.kernel.org --- In rmi_f12_read_sensor_tuning() we call rmi_register_desc_has_subpacket() to check the subpacket map to make sure a subpacket exists to ensure that the buffer contains the correct data. It happened that on my the test devices the register we were checking was also the first register. This issues showed up on newer devices where F12 CTRL 8 is not teh first control register. V2 moves map_offset closer to the do/while loop. Thanks, Andrew drivers/input/rmi4/rmi_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index 2b6b97e..00f9ad9 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -553,7 +553,6 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, goto free_struct_buff; reg = find_first_bit(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS); - map_offset = 0; for (i = 0; i < rdesc->num_registers; i++) { struct rmi_register_desc_item *item = &rdesc->registers[i]; int reg_size = struct_buf[offset]; @@ -576,6 +575,8 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, item->reg = reg; item->reg_size = reg_size; + map_offset = 0; + do { for (b = 0; b < 7; b++) { if (struct_buf[offset] & (0x1 << b))