From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Torokhov Subject: Re: [PATCH v2 1/2] Input: soc_button_array: Get rid of MAX_NBUTTONS Date: Fri, 17 Mar 2017 14:08:31 -0700 Message-ID: <20170317210831.GD26166@dtor-ws> References: <20170317140942.24368-1-hdegoede@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:35462 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbdCQVJc (ORCPT ); Fri, 17 Mar 2017 17:09:32 -0400 Received: by mail-pf0-f196.google.com with SMTP id x63so9677669pfx.2 for ; Fri, 17 Mar 2017 14:08:34 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20170317140942.24368-1-hdegoede@redhat.com> Sender: linux-input-owner@vger.kernel.org List-Id: linux-input@vger.kernel.org To: Hans de Goede Cc: "russianneuromancer @ ya . ru" , linux-input@vger.kernel.org On Fri, Mar 17, 2017 at 03:09:41PM +0100, Hans de Goede wrote: > Count how much gpio_keys we actually need, this is a preparation patch > for adding support for the new Win10 / ACPI-6.0 "Generic Buttons Device" > support. > > Signed-off-by: Hans de Goede Applied, thank you. > --- > drivers/input/misc/soc_button_array.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c > index 0cd2cac..b8769f6 100644 > --- a/drivers/input/misc/soc_button_array.c > +++ b/drivers/input/misc/soc_button_array.c > @@ -20,13 +20,6 @@ > #include > #include > > -/* > - * Definition of buttons on the tablet. The ACPI index of each button > - * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC > - * Platforms" > - */ > -#define MAX_NBUTTONS 5 > - > struct soc_button_info { > const char *name; > int acpi_index; > @@ -79,14 +72,19 @@ soc_button_device_create(struct platform_device *pdev, > int gpio; > int error; > > + for (info = button_info; info->name; info++) > + if (info->autorepeat == autorepeat) > + n_buttons++; > + > gpio_keys_pdata = devm_kzalloc(&pdev->dev, > sizeof(*gpio_keys_pdata) + > - sizeof(*gpio_keys) * MAX_NBUTTONS, > + sizeof(*gpio_keys) * n_buttons, > GFP_KERNEL); > if (!gpio_keys_pdata) > return ERR_PTR(-ENOMEM); > > gpio_keys = (void *)(gpio_keys_pdata + 1); > + n_buttons = 0; > > for (info = button_info; info->name; info++) { > if (info->autorepeat != autorepeat) > @@ -200,6 +198,11 @@ static int soc_button_probe(struct platform_device *pdev) > return 0; > } > > +/* > + * Definition of buttons on the tablet. The ACPI index of each button > + * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC > + * Platforms" > + */ > static struct soc_button_info soc_button_PNP0C40[] = { > { "power", 0, EV_KEY, KEY_POWER, false, true }, > { "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, > -- > 2.9.3 > -- Dmitry