From patchwork Fri Mar 17 14:09:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9630839 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 4013860245 for ; Fri, 17 Mar 2017 14:19:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2734B2852D for ; Fri, 17 Mar 2017 14:19:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BE1C2857D; Fri, 17 Mar 2017 14:19:37 +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 B37832852D for ; Fri, 17 Mar 2017 14:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751037AbdCQOTS (ORCPT ); Fri, 17 Mar 2017 10:19:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38889 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751064AbdCQORr (ORCPT ); Fri, 17 Mar 2017 10:17:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DFD87971D; Fri, 17 Mar 2017 14:09:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1DFD87971D Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1DFD87971D Received: from dhcp-45-79.space.revspace.nl.com (ovpn-117-147.ams2.redhat.com [10.36.117.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A93A1899B; Fri, 17 Mar 2017 14:09:46 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: "russianneuromancer @ ya . ru" , linux-input@vger.kernel.org, Hans de Goede Subject: [PATCH v2 1/2] Input: soc_button_array: Get rid of MAX_NBUTTONS Date: Fri, 17 Mar 2017 15:09:41 +0100 Message-Id: <20170317140942.24368-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 17 Mar 2017 14:09:47 +0000 (UTC) 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 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 --- 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 },