Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759615AbcJYVO3 (ORCPT ); Tue, 25 Oct 2016 17:14:29 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34410 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759526AbcJYVO0 (ORCPT ); Tue, 25 Oct 2016 17:14:26 -0400 MIME-Version: 1.0 In-Reply-To: <1477427791-1094-1-git-send-email-nick@shmanahar.org> References: <1477427791-1094-1-git-send-email-nick@shmanahar.org> From: Chris Healy Date: Tue, 25 Oct 2016 14:14:25 -0700 Message-ID: Subject: Re: [PATCH v2] Input: synaptics-rmi4 - stop scanning PDT after two empty pages To: Nick Dyer Cc: Dmitry Torokhov , Andrew Duggan , Christopher Heiny , Guenter Roeck , linux-input@vger.kernel.org, linux-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2561 Lines: 65 On Tue, Oct 25, 2016 at 1:36 PM, Nick Dyer wrote: > 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 > --- > 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; > } > -- > 2.7.4 > Tested successfully on S7817 and S7300 Synaptics touch controllers. The S7300 has no regressions and the S7817 now shows fn55 in the sysfs. (It did not show fn55 before the patch.) Tested-by: Chris Healy