diff options
Diffstat (limited to 'drivers/input/gpio_keys.c')
-rw-r--r-- | drivers/input/gpio_keys.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/input/gpio_keys.c b/drivers/input/gpio_keys.c index 38c0f11535..c897acf3bd 100644 --- a/drivers/input/gpio_keys.c +++ b/drivers/input/gpio_keys.c @@ -1,7 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> - * - * Under GPLv2 */ #include <common.h> @@ -30,24 +29,24 @@ struct gpio_keys { struct gpio_key *buttons; int nbuttons; - struct poller_struct poller; + struct poller_async poller; struct input_device input; - struct device_d *dev; }; -static inline struct gpio_keys * -poller_to_gk_pdata(struct poller_struct *poller) +static void gpio_key_poller(void *data) { - return container_of(poller, struct gpio_keys, poller); -} - -static void gpio_key_poller(struct poller_struct *poller) -{ - struct gpio_keys *gk = poller_to_gk_pdata(poller); + struct gpio_keys *gk = data; struct gpio_key *gb; int i, val; for (i = 0; i < gk->nbuttons; i++) { + gb = &gk->buttons[i]; + + if (gpio_slice_acquired(gb->gpio)) + goto out; + } + + for (i = 0; i < gk->nbuttons; i++) { gb = &gk->buttons[i]; val = gpio_get_value(gb->gpio); @@ -60,14 +59,16 @@ static void gpio_key_poller(struct poller_struct *poller) gb->debounce_start = get_time_ns(); input_report_key_event(&gk->input, gb->code, pressed); - dev_dbg(gk->dev, "%s gpio(%d) as %d\n", + dev_dbg(gk->input.parent, "%s gpio(%d) as %d\n", pressed ? "pressed" : "released", gb->gpio, gb->code); gb->previous_state = val; } } +out: + poller_call_async(&gk->poller, 10 * MSECOND, gpio_key_poller, gk); } -static int gpio_keys_probe_pdata(struct gpio_keys *gk, struct device_d *dev) +static int gpio_keys_probe_pdata(struct gpio_keys *gk, struct device *dev) { struct gpio_keys_platform_data *pdata; int i; @@ -93,9 +94,9 @@ static int gpio_keys_probe_pdata(struct gpio_keys *gk, struct device_d *dev) return 0; } -static int gpio_keys_probe_dt(struct gpio_keys *gk, struct device_d *dev) +static int gpio_keys_probe_dt(struct gpio_keys *gk, struct device *dev) { - struct device_node *npkey, *np = dev->device_node; + struct device_node *npkey, *np = dev->of_node; int i = 0, ret; if (!IS_ENABLED(CONFIG_OFDEVICE) || !IS_ENABLED(CONFIG_OF_GPIO)) @@ -132,16 +133,14 @@ static int gpio_keys_probe_dt(struct gpio_keys *gk, struct device_d *dev) return 0; } -static int __init gpio_keys_probe(struct device_d *dev) +static int __init gpio_keys_probe(struct device *dev) { int ret, i, gpio; struct gpio_keys *gk; gk = xzalloc(sizeof(*gk)); - gk->dev = dev; - - if (dev->device_node) + if (dev->of_node) ret = gpio_keys_probe_dt(gk, dev); else ret = gpio_keys_probe_pdata(gk, dev); @@ -160,16 +159,17 @@ static int __init gpio_keys_probe(struct device_d *dev) gk->buttons[i].previous_state = gk->buttons[i].active_low; } - gk->poller.func = gpio_key_poller; - + gk->input.parent = dev; ret = input_device_register(&gk->input); if (ret) return ret; - ret = poller_register(&gk->poller); + ret = poller_async_register(&gk->poller, dev_name(dev)); if (ret) return ret; + poller_call_async(&gk->poller, 10 * MSECOND, gpio_key_poller, gk); + return 0; } @@ -177,8 +177,9 @@ static struct of_device_id key_gpio_of_ids[] = { { .compatible = "gpio-keys", }, { } }; +MODULE_DEVICE_TABLE(of, key_gpio_of_ids); -static struct driver_d gpio_keys_driver = { +static struct driver gpio_keys_driver = { .name = "gpio_keys", .probe = gpio_keys_probe, .of_compatible = DRV_OF_COMPAT(key_gpio_of_ids), |