提交 7283b47d 编写于 作者: H Hans de Goede 提交者: Dmitry Torokhov

Input: soc_button_array - get rid of MAX_NBUTTONS

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: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
上级 2e2a0db8
...@@ -20,13 +20,6 @@ ...@@ -20,13 +20,6 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
/*
* 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 { struct soc_button_info {
const char *name; const char *name;
int acpi_index; int acpi_index;
...@@ -79,14 +72,19 @@ soc_button_device_create(struct platform_device *pdev, ...@@ -79,14 +72,19 @@ soc_button_device_create(struct platform_device *pdev,
int gpio; int gpio;
int error; int error;
for (info = button_info; info->name; info++)
if (info->autorepeat == autorepeat)
n_buttons++;
gpio_keys_pdata = devm_kzalloc(&pdev->dev, gpio_keys_pdata = devm_kzalloc(&pdev->dev,
sizeof(*gpio_keys_pdata) + sizeof(*gpio_keys_pdata) +
sizeof(*gpio_keys) * MAX_NBUTTONS, sizeof(*gpio_keys) * n_buttons,
GFP_KERNEL); GFP_KERNEL);
if (!gpio_keys_pdata) if (!gpio_keys_pdata)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
gpio_keys = (void *)(gpio_keys_pdata + 1); gpio_keys = (void *)(gpio_keys_pdata + 1);
n_buttons = 0;
for (info = button_info; info->name; info++) { for (info = button_info; info->name; info++) {
if (info->autorepeat != autorepeat) if (info->autorepeat != autorepeat)
...@@ -200,6 +198,11 @@ static int soc_button_probe(struct platform_device *pdev) ...@@ -200,6 +198,11 @@ static int soc_button_probe(struct platform_device *pdev)
return 0; 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[] = { static struct soc_button_info soc_button_PNP0C40[] = {
{ "power", 0, EV_KEY, KEY_POWER, false, true }, { "power", 0, EV_KEY, KEY_POWER, false, true },
{ "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, { "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册