From patchwork Wed Oct 26 20:57:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Dyer X-Patchwork-Id: 9398323 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 A83BA60234 for ; Wed, 26 Oct 2016 20:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8309D29D82 for ; Wed, 26 Oct 2016 20:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77AB229DE7; Wed, 26 Oct 2016 20:57:49 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 9DF3729D82 for ; Wed, 26 Oct 2016 20:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933128AbcJZU5r (ORCPT ); Wed, 26 Oct 2016 16:57:47 -0400 Received: from avasout06.plus.net ([212.159.14.18]:51129 "EHLO avasout06.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932673AbcJZU5q (ORCPT ); Wed, 26 Oct 2016 16:57:46 -0400 Received: from lava ([80.229.148.18]) by avasout06 with smtp id 0Lxf1u0030Q3Geg01LxgEh; Wed, 26 Oct 2016 21:57:44 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=apbwMmRV c=1 sm=1 tr=0 a=o7Djd4SkmPXITDn8qH+ssQ==:117 a=o7Djd4SkmPXITDn8qH+ssQ==:17 a=CH0kA5CcgfcA:10 a=beXlt2xKAAAA:8 a=pGLkceISAAAA:8 a=swAopTDVAAAA:8 a=bp1g5Iz1D7c7guLF1_8A:9 a=gcY2M4Ci8LIz02MwfSIM:22 a=6kGIvZw6iX1k4Y-7sg4_:22 a=7aPqbiTMDNvH6kBvy-t8:22 Received: from nick by lava with local (Exim 4.86_2) (envelope-from ) id 1bzVGV-0000FC-5L; Wed, 26 Oct 2016 21:57:39 +0100 From: Nick Dyer To: Dmitry Torokhov , Andrew Duggan , Christopher Heiny , Guenter Roeck Cc: Chris Healy , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Dyer Subject: [PATCH v3] Input: synaptics-rmi4 - stop scanning PDT after two empty pages Date: Wed, 26 Oct 2016 21:57:34 +0100 Message-Id: <1477515454-900-1-git-send-email-nick@shmanahar.org> X-Mailer: git-send-email 2.7.4 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 We have encountered some RMI4 firmwares where there are blank pages in between PDT pages which contain functions. This change makes them correctly enumerate all functions on the device. Tested on S7817 (has empty page 2). Signed-off-by: Nick Dyer [Tested successfully on S7817 and S7300 Synaptics touch controllers] Tested-by: Chris Healy Reviewed-by: Andrew Duggan --- drivers/input/rmi4/rmi_driver.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index 4a88312..425bd19 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -422,6 +422,7 @@ static void rmi_driver_copy_pdt_to_fd(const struct pdt_entry *pdt, static int rmi_scan_pdt_page(struct rmi_device *rmi_dev, int page, + int *empty_pages, void *ctx, int (*callback)(struct rmi_device *rmi_dev, void *ctx, @@ -449,7 +450,16 @@ static int rmi_scan_pdt_page(struct rmi_device *rmi_dev, return retval; } - return (data->f01_bootloader_mode || addr == pdt_start) ? + /* + * Count number of empty PDT pages. If a gap of two pages + * or more is found, stop scanning. + */ + if (addr == pdt_start) + ++*empty_pages; + else + *empty_pages = 0; + + return (data->f01_bootloader_mode || *empty_pages >= 2) ? RMI_SCAN_DONE : RMI_SCAN_CONTINUE; } @@ -459,10 +469,12 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx, const struct pdt_entry *entry)) { int page; + int empty_pages = 0; int retval = RMI_SCAN_DONE; for (page = 0; page <= RMI4_MAX_PAGE; page++) { - retval = rmi_scan_pdt_page(rmi_dev, page, ctx, callback); + retval = rmi_scan_pdt_page(rmi_dev, page, &empty_pages, + ctx, callback); if (retval != RMI_SCAN_CONTINUE) break; }