aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/gpio_keys.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-05-26Input: gpio-keys - cancel delayed work only in case of GPIOLad Prabhakar1-1/+1
gpio_keys module can either accept gpios or interrupts. The module initializes delayed work in case of gpios only and is only used if debounce timer is not used, so make sure cancel_delayed_work_sync() is called only when its gpio-backed and debounce_use_hrtimer is false. This fixes the issue seen below when the gpio_keys module is unloaded and an interrupt pin is used instead of GPIO: [ 360.297569] ------------[ cut here ]------------ [ 360.302303] WARNING: CPU: 0 PID: 237 at kernel/workqueue.c:3066 __flush_work+0x414/0x470 [ 360.310531] Modules linked in: gpio_keys(-) [ 360.314797] CPU: 0 PID: 237 Comm: rmmod Not tainted 5.18.0-rc5-arm64-renesas-00116-g73636105874d-dirty #166 [ 360.324662] Hardware name: Renesas SMARC EVK based on r9a07g054l2 (DT) [ 360.331270] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 360.338318] pc : __flush_work+0x414/0x470 [ 360.342385] lr : __cancel_work_timer+0x140/0x1b0 [ 360.347065] sp : ffff80000a7fba00 [ 360.350423] x29: ffff80000a7fba00 x28: ffff000012b9c5c0 x27: 0000000000000000 [ 360.357664] x26: ffff80000a7fbb80 x25: ffff80000954d0a8 x24: 0000000000000001 [ 360.364904] x23: ffff800009757000 x22: 0000000000000000 x21: ffff80000919b000 [ 360.372143] x20: ffff00000f5974e0 x19: ffff00000f5974e0 x18: ffff8000097fcf48 [ 360.379382] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000053f40 [ 360.386622] x14: ffff800009850e88 x13: 0000000000000002 x12: 000000000000a60c [ 360.393861] x11: 000000000000a610 x10: 0000000000000000 x9 : 0000000000000008 [ 360.401100] x8 : 0101010101010101 x7 : 00000000a473c394 x6 : 0080808080808080 [ 360.408339] x5 : 0000000000000001 x4 : 0000000000000000 x3 : ffff80000919b458 [ 360.415578] x2 : ffff8000097577f0 x1 : 0000000000000001 x0 : 0000000000000000 [ 360.422818] Call trace: [ 360.425299] __flush_work+0x414/0x470 [ 360.429012] __cancel_work_timer+0x140/0x1b0 [ 360.433340] cancel_delayed_work_sync+0x10/0x18 [ 360.437931] gpio_keys_quiesce_key+0x28/0x58 [gpio_keys] [ 360.443327] devm_action_release+0x10/0x18 [ 360.447481] release_nodes+0x8c/0x1a0 [ 360.451194] devres_release_all+0x90/0x100 [ 360.455346] device_unbind_cleanup+0x14/0x60 [ 360.459677] device_release_driver_internal+0xe8/0x168 [ 360.464883] driver_detach+0x4c/0x90 [ 360.468509] bus_remove_driver+0x54/0xb0 [ 360.472485] driver_unregister+0x2c/0x58 [ 360.476462] platform_driver_unregister+0x10/0x18 [ 360.481230] gpio_keys_exit+0x14/0x828 [gpio_keys] [ 360.486088] __arm64_sys_delete_module+0x1e0/0x270 [ 360.490945] invoke_syscall+0x40/0xf8 [ 360.494661] el0_svc_common.constprop.3+0xf0/0x110 [ 360.499515] do_el0_svc+0x20/0x78 [ 360.502877] el0_svc+0x48/0xf8 [ 360.505977] el0t_64_sync_handler+0x88/0xb0 [ 360.510216] el0t_64_sync+0x148/0x14c [ 360.513930] irq event stamp: 4306 [ 360.517288] hardirqs last enabled at (4305): [<ffff8000080b0300>] __cancel_work_timer+0x130/0x1b0 [ 360.526359] hardirqs last disabled at (4306): [<ffff800008d194fc>] el1_dbg+0x24/0x88 [ 360.534204] softirqs last enabled at (4278): [<ffff8000080104a0>] _stext+0x4a0/0x5e0 [ 360.542133] softirqs last disabled at (4267): [<ffff8000080932ac>] irq_exit_rcu+0x18c/0x1b0 [ 360.550591] ---[ end trace 0000000000000000 ]--- Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://lore.kernel.org/r/20220524135822.14764-1-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-01-03Input: gpio-keys - avoid clearing twice some memoryChristophe JAILLET1-1/+1
bitmap_parselist() already clears the 'bits' bitmap, so there is no need to clear it when it is allocated. This just wastes some cycles. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/d6ee621b9dd75b92f8831db365cee58dc2025322.1640813136.git.christophe.jaillet@wanadoo.fr Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2021-04-07Input: gpio-keys - fix crash when disabliing GPIO-less buttonsDmitry Torokhov1-17/+13
My brain-damaged adjustments to Paul's patch caused crashes in gpio_keys_disable_button() when driver is used in GPIO-less (i.e. purely interrupt-driven) setups, because I mixed together debounce and release timers when they are in fact separate: Unable to handle kernel NULL pointer dereference at virtual address 0000000c ... PC is at hrtimer_active+0xc/0x98 LR is at hrtimer_try_to_cancel+0x24/0x140 ... [<c01c43b8>] (hrtimer_active) from [<c01c50f4>] (hrtimer_try_to_cancel+0x24/0x140) [<c01c50f4>] (hrtimer_try_to_cancel) from [<c01c5224>] (hrtimer_cancel+0x14/0x4c) [<c01c5224>] (hrtimer_cancel) from [<bf1cae24>] (gpio_keys_attr_store_helper+0x1b8/0x1d8 [gpio_keys]) [<bf1cae24>] (gpio_keys_attr_store_helper [gpio_keys]) from [<bf1cae80>] (gpio_keys_store_disabled_keys+0x18/0x24 [gpio_keys]) [<bf1cae80>] (gpio_keys_store_disabled_keys [gpio_keys]) from [<c038ec7c>] (kernfs_fop_write_iter+0x10c/0x1cc) [<c038ec7c>] (kernfs_fop_write_iter) from [<c02df858>] (vfs_write+0x2ac/0x404) [<c02df858>] (vfs_write) from [<c02dfaf4>] (ksys_write+0x64/0xdc) [<c02dfaf4>] (ksys_write) from [<c0100080>] (ret_fast_syscall+0x0/0x58) Let's fix it up. Fixes: c9efb0ba281e ("Input: gpio-keys - use hrtimer for software debounce, if possible") Reported-by: Tony Lindgren <tony@atomide.com> Tested-by: Tony Lindgren <tony@atomide.com> Link: https://lore.kernel.org/r/YG1DFFgojSVfdpaz@google.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2021-03-25Input: gpio-keys - use hrtimer for software debounce, if possiblePaul Cercueil1-14/+52
We want to be able to report the input event as soon as the debounce delay elapsed. However, the current code does not really ensure that, as it uses the jiffies-based schedule_delayed_work() API. With a small enough HZ value (HZ <= 100), this results in some input events being lost, when a key is quickly pressed then released (on a human's time scale). Switching to hrtimers fixes this issue, and will work even on extremely low HZ values (tested at HZ=24). This is however only possible if reading the GPIO is possible without sleeping. If this condition is not met, the previous approach of using a jiffies-based timer is taken. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20210307222240.380583-3-paul@crapouillou.net Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2021-03-25Input: gpio-keys - use hrtimer for release timerPaul Cercueil1-11/+16
Dealing with input, timing is important; if the button should be released in one millisecond, then it should be done in one millisecond and not a hundred milliseconds. Therefore, the standard timer API is not really suitable for this task. Convert the gpio-keys driver to use a hrtimer instead of the standard timer to address this issue. Note that by using a hard IRQ for the hrtimer callback, we can get rid of the spin_lock_irqsave() and spin_unlock_irqrestore(). Signed-off-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20210307222240.380583-2-paul@crapouillou.net Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2021-03-25Input: gpio-keys - remove extra call to input_syncPaul Cercueil1-1/+1
The input_sync() function is already called after the loop in gpio_keys_report_state(), so it does not need to be called after each iteration within gpio_keys_gpio_report_event(). Signed-off-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20210307222240.380583-1-paul@crapouillou.net Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-12-02Input: use input_device_enabled()Andrzej Pietrasiewicz1-2/+2
Use the newly added helper in relevant input drivers. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> Link: https://lore.kernel.org/r/20200608112211.12125-3-andrzej.p@collabora.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-11-08Input: gpio_keys - fix misnamed function parameter 'dev'Lee Jones1-1/+1
Fixes the following W=1 kernel build warning(s): drivers/input/keyboard/gpio_keys.c:119: warning: Function parameter or member 'dev' not described in 'get_bm_events_by_type' drivers/input/keyboard/gpio_keys.c:119: warning: Excess function parameter 'input' description in 'get_bm_events_by_type' Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20201104162427.2984742-12-lee.jones@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-07-07Input: Use fallthrough pseudo-keywordGustavo A. R. Silva1-1/+0
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20200707180857.GA30600@embeddedor Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-02-13Input: gpio_keys - replace zero-length array with flexible-array memberGustavo A. R. Silva1-1/+1
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Link: https://lore.kernel.org/r/20200213002600.GA31916@embeddedor.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-10-27Input: gpio_keys - switch to using devm_fwnode_gpiod_get()Dmitry Torokhov1-4/+2
devm_fwnode_get_gpiod_from_child() is going away as the name is too unwieldy, let's switch to using the new devm_fwnode_gpiod_get(). Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-08-12Input: gpio_keys - convert driver to use dev_groupsGreg Kroah-Hartman1-11/+2
Drivers now have the option to have the driver core create and remove any needed sysfs attribute files. So take advantage of that and do not register "by hand" a bunch of sysfs files. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-07-15Merge tag 'v5.2' into nextDmitry Torokhov1-4/+1
Sync up with mainline to resolve conflicts in iforce driver.
2019-06-22Input: gpio_keys - use struct_size() in devm_kzalloc()Gustavo A. R. Silva1-4/+2
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct gpio_keys_drvdata { ... struct gpio_button_data data[0]; }; size = sizeof(struct gpio_keys_drvdata) + count * sizeof(struct gpio_button_data); instance = devm_kzalloc(dev, size, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = devm_kzalloc(dev, struct_size(instance, data, count), GFP_KERNEL); Notice that, in this case, variable size is not necessary, hence it is removed. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-4/+1
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-06Input: gpio-keys - add shutdown callbackFlorian Fainelli1-0/+10
On some platforms (e.g.: ARCH_BRCMSTB) it is possible to enter "poweroff" while leaving some wake-up sources enabled such as key presses in order to allow for the system to wake-up. Wire up a .shutdown() callback which calls into the existing gpio_keys_suspend() since the logic is essentially the same. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2018-08-01Input: gpio-keys - switch to bitmap_zalloc()Andy Shevchenko1-4/+4
Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2018-03-14Input: gpio-keys - add support for wakeup event actionJeffy Chen1-14/+131
Add support for specifying event actions to trigger wakeup when using the gpio-keys input device as a wakeup source. This would allow the device to configure when to wakeup the system. For example a gpio-keys input device for pen insert, may only want to wakeup the system when ejecting the pen. Suggested-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-10-23Input: gpio-keys - convert timers to use timer_setup()stephen lu1-4/+3
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Signed-off-by: Stephen Lu <lumotuwe@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-07-24Merge branch 'bind_unbind' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core into nextDmitry Torokhov1-14/+2
This brings in devm_device_add_group() and friends so that we can create driver-specific device attributes as managed resources.
2017-07-22Input: gpio_keys - use devm_device_add_group() for attributesDmitry Torokhov1-14/+2
Now that we have proper managed API to create device attributes, let's start using it instead of the manual unwinding. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-12Input: gpio_keys - constify attribute_group structuresArvind Yadav1-1/+1
attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 5693 464 0 6157 180d drivers/input/keyboard/gpio_keys.o File size After adding 'const': text data bss dec hex filename 5749 400 0 6149 1805 drivers/input/keyboard/gpio_keys.o Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-07-09Input: gpio_keys - handle the missing key press event in resume phaseJoseph Lo1-1/+16
The GPIO key press event might be missed in the resume phase, if the key had been released before the system had been resumed to the stage that it could capture the press event. So we simulate the wakeup key press event in case the key had been released by the time we got interrupt handler to run. Signed-off-by: Joseph Lo <josephl@nvidia.com> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-02-23Merge tag 'gpio-v4.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpioLinus Torvalds1-8/+4
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v4.11 cycle Core changes: - Augment fwnode_get_named_gpiod() to configure the GPIO pin immediately after requesting it like all other APIs do. This is a treewide change also updating all users. - Pass a GPIO label down to gpiod_request() from fwnode_get_named_gpiod(). This makes debugfs and the userspace ABI correctly reflect the current in-kernel consumer of a pin taken using this abstraction. This is a treewide change also updating all users. - Rename devm_get_gpiod_from_child() to devm_fwnode_get_gpiod_from_child() to reflect the fact that this function is operating on a fwnode object. This is a treewide change also updating all users. - Make it possible to take multiple GPIOs in a single hog of device tree hogs. - The refactorings switching GPIO chips to use the .set_config() callback using standard pin control properties and providing a backend into the pin control subsystem that were also merged into the pin control tree naturally appear here too. Testing instrumentation: - A whole slew of cleanups and improvements to the mockup GPIO driver. We now have an extended userspace test exercising the subsystem, and we can inject interrupts etc from userspace to fully test the core GPIO functionality. New drivers: - New driver for the Cortina Systems Gemini GPIO controller. - New driver for the Exar XR17V352/354/358 chips. - New driver for the ACCES PCI-IDIO-16 PCI GPIO card. Driver changes: - RCAR: set the irqchip parent device, add fine-grained runtime PM support. - pca953x: support optional RESET control line on the chip. - DaVinci: cleanups and simplifications. Add support for multiple instances. - .set_multiple() and naming of lines on more or less all of the ISA/PCI GPIO controllers. - mcp23s08: refactored to use regmap as a first step to further rewrites and modernizations" * tag 'gpio-v4.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (61 commits) gpio: reintroduce devm_get_gpiod_from_child() gpio: pci-idio-16: Fix PCI BAR index gpio: pci-idio-16: Fix PCI device ID code gpio: mockup: implement event injecting over debugfs gpio: mockup: add a dummy irqchip gpio: mockup: implement naming the lines gpio: mockup: code shrink gpio: mockup: readability tweaks gpio: Add GPIO support for the ACCES PCI-IDIO-16 gpio: Add the devm_fwnode_get_index_gpiod_from_child() helper gpio: Rename devm_get_gpiod_from_child() gpio: mcp23s08: Select REGMAP/REGMAP_I2C to fix build error gpio: ws16c48: Add support for GPIO names gpio: gpio-mm: Add support for GPIO names gpio: 104-idio-16: Add support for GPIO names gpio: 104-idi-48: Add support for GPIO names gpio: 104-dio-48e: Add support for GPIO names gpio: ws16c48: Remove unnecessary driver_data set gpio: gpio-mm: Remove unnecessary driver_data set gpio: 104-idio-16: Remove unnecessary driver_data set ...
2017-02-04gpio: Rename devm_get_gpiod_from_child()Boris Brezillon1-2/+4
Rename devm_get_gpiod_from_child() into devm_fwnode_get_gpiod_from_child() to reflect the fact that this function is operating on a fwnode object. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-01-26gpio: Pass GPIO label down to gpiod_requestAlexander Stein1-1/+2
Currently all users of fwnode_get_named_gpiod() have no way to specify a label for the GPIO. So GPIOs listed in debugfs are shown with label "?". With this change a proper label is used. Also adjust all users so they can pass a label, properly retrieved from device tree properties. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-01-26gpiolib: Convert fwnode_get_named_gpiod() to configure GPIOAndy Shevchenko1-8/+1
Make fwnode_get_named_gpiod() consistent with the rest of gpiod_get() like API, i.e. configure GPIO pin immediately after request. Besides obvious clean up it will help to configure pins based on firmware provided resources. Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-01-21Input: keyboard - drop unnecessary calls to device_init_wakeupGuenter Roeck1-2/+0
Calling device_init_wakeup in the remove function is unnecessary since the device is going away, and thus won't be able to cause any wakeups under any circumstances. Besides, the driver cleanup code already handles the necessary cleanup. Similarly, disabling wakeup in the probe error path is unnecessary, as is disabling wakeup in the probe function in the first place. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-01-21Input: keyboard - use local variables consistentlyGuenter Roeck1-13/+11
If a function declares a variable to access a structure element, use it consistently. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-01-21Input: gpio-keys - add support for setkeycodeHans de Goede1-12/+28
gpio-keys input devices created by the soc_button_array driver are configured with key-codes based on ACPI provided information. Unfortunately on some tablets this info is wrong, and we need to have a quirk to fix things up. Add support for input_setkeycode to the gpio-keys driver, so that the existing udev hwdb mechanism can be used to fix things up on these tablets. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-11-17Input: gpio_keys - set input direction explicitlySudeep Holla1-0/+7
Commit 700a38b27eef ("Input: gpio_keys - switch to using generic device properties") switched to use generic device properties for GPIO keys and commit 5feeca3c1e39 ("Input: gpio_keys - add support for GPIO descriptors") switched from legacy GPIO numbers to GPIO descriptors. Previously devm_gpio_request_one was explicitly passed GPIOF_DIR_IN flag to set the GPIO direction as input. However devm_get_gpiod_from_child doesn't have such provisions and hence fwnode_get_named_gpiod can't set it as input. This breaks few platforms with the following error: " gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ unable to lock HW IRQ <n> for IRQ genirq: Failed to request resources for POWER (irq <x>) on irqchip gpio_keys: Unable to claim irq <x>; error -22 gpio-keys: probe failed with error -22 " This patch fixes the issue by setting input direction explicitly for gpio lines described by generic properties. Fixes: 700a38b27eef ("Input: gpio_keys - switch to using generic device properties") Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-11-07Input: gpio_keys - switch to using generic device propertiesDmitry Torokhov1-72/+69
Make use of the device property API in this driver so that both OF based systems and ACPI based systems can use this driver. Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be> Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-11-07Input: gpio_keys - add support for GPIO descriptorsGeert Uytterhoeven1-11/+26
GPIO descriptors are the preferred way over legacy GPIO numbers nowadays. Convert the driver to use GPIO descriptors internally but still allow passing legacy GPIO numbers from platform data to support existing platforms. Based on commits 633a21d80b4a2cd6 ("input: gpio_keys_polled: Add support for GPIO descriptors") and 1ae5ddb6f8837558 ("Input: gpio_keys_polled - request GPIO pin as input."). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-11-07Input: gpio_keys - fix leaking DT node referencesDmitry Torokhov1-0/+3
for_each_available_child_of_node(node, pp) takes reference to 'pp' and drops it when attempting next iteration. However if we exit the loop early we need to drop the reference ourselves. Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-11-07Input: gpio_keys - annotate PM methods as __maybe_unusedDmitry Torokhov1-4/+2
Instead of using #ifdef, let's mark suspend and resume methods as __maybe_unused to provide better compile coverage. Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-11-07Input: gpio_keys_polled - keep button data constantDmitry Torokhov1-5/+5
Commit 633a21d80b4a ("input: gpio_keys_polled: Add support for GPIO descriptors") placed gpio descriptor into gpio_keys_button structure, which is supposed to be part of platform data and not modifiable by the driver. To keep the data constant, let's move the descriptor to gpio_keys_button_data structure instead. Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-01-13Input: gpio-keys - allow disabling individual buttons in DTLaxman Dewangan1-2/+2
Add support to disable buttons from DT via status property if given button is not supported on given platforms. This will help re-using existing dtsi files across multiple platforms. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-01-13Input: gpio-keys - allow setting input device name in DTLaxman Dewangan1-0/+2
Allow specifying name if input device via device tree property. This helps userspace code to get name and perform proper event to key mapping in some cases (for example, on Android). Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-01-10Input: gpio-keys - fix check for disabling unsupported keysDmitry Torokhov1-6/+23
Commit 4ea14a53d8f881034fa9e186653821c4e3d9a8fb ("Input: gpio-keys - report error when disabling unsupported key") tried let user know that they attempted to disable an unsupported key, unfortunately the check is wrong as it believes that all codes are invalid. Fix it by ensuring that keys that we try to disable are subset of keys (or switches) that device reports. Fixes: 4ea14a53d8f8 ("Input: gpio-keys - report error when disabling unsupported key") Reported-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> Tested-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-10-02Input: gpio_keys - don't report events on gpio failureBjorn Andersson1-1/+7
In the cases where the gpio chip fails to acquire the current state an error is reported back to gpio_keys. This is currently interpreted as if the line went high, which just confuses the developer. This patch introduces an error print in this case and skipps the reporting of a input event; to aid in debugging this issue. Reported-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-08-24Input: gpio-keys - report error when disabling unsupported keyPeng Fan1-0/+5
When trying to disable a key that is not supported by the device we should report error, not do nothing and report success: root@yocto:/sys/devices/soc0/gpio-keys# cat keys 114-116 root@yocto:/sys/devices/soc0/gpio-keys# echo 77 > keys root@yocto:/sys/devices/soc0/gpio-keys# We want 'echo 77 > keys' to report an error, but silence to give us an illusion that all is 'ok'. Signed-off-by: Peng Fan <van.freenix@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-07-23Input: gpio_keys[_polled] - change name of wakeup propertyDmitry Torokhov1-1/+3
Wakeup property of device is not Linux-specific, it describes intended system behavior regardless of the OS being used. Therefore let's drop "linux," prefix, and, while at it, use the same name as I2C bus does: "wakeup-source". We keep parsing old name to keep compatibility with old DTSes. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-02-13input: use %*pb[l] to print bitmaps including cpumasks and nodemasksTejun Heo1-1/+1
printk and friends can now format bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask. * Line termination only requires one extra space at the end of the buffer. Use PAGE_SIZE - 1 instead of PAGE_SIZE - 2 when formatting. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-12-30Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/inputLinus Torvalds1-57/+57
Pull input layer fixes from Dmitry Torokhov: "Fixes for v7 protocol for ALPS devices and few other driver fixes. Also users can request input events to be stamped with boot time timestamps, in addition to real and monotonic timestamps" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: hil_kbd - fix incorrect use of init_completion Input: alps - v7: document the v7 touchpad packet protocol Input: alps - v7: fix finger counting for > 2 fingers on clickpads Input: alps - v7: sometimes a single touch is reported in mt[1] Input: alps - v7: ignore new packets Input: evdev - add CLOCK_BOOTTIME support Input: psmouse - expose drift duration for IBM trackpoints Input: stmpe - bias keypad columns properly Input: stmpe - enforce device tree only mode mfd: stmpe: add pull up/down register offsets for STMPE Input: optimize events_per_packet count calculation Input: edt-ft5x06 - fixed a macro coding style issue Input: gpio_keys - replace timer and workqueue with delayed workqueue Input: gpio_keys - allow separating gpio and irq in device tree
2014-12-17Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/inputLinus Torvalds1-16/+21
Pull input subsystem updates from Dmitry Torokhov: "Two new drivers for Elan hardware (for I2C touchpad and touchscreen found in several Chromebooks and other devices), a driver for Goodix touch panel, and small fixes to Cypress I2C trackpad and other input drivers. Also we switched to use __maybe_unused instead of gating suspend/ resume code with #ifdef guards to get better compile coverage" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (27 commits) Input: gpio_keys - fix warning regarding uninitialized 'button' variable Input: add support for Elan eKTH I2C touchscreens Input: gpio_keys - fix warning regarding uninitialized 'irq' variable Input: cyapa - use 'error' for error codes Input: cyapa - fix resuming the device Input: gpio_keys - add device tree support for interrupt only keys Input: amikbd - allocate temporary keymap buffer on the stack Input: amikbd - fix build if !CONFIG_HW_CONSOLE Input: lm8323 - missing error check in lm8323_set_disable() Input: initialize device counter variables with -1 Input: initialize input_no to -1 to avoid subtraction Input: i8042 - do not try to load on Intel NUC D54250WYK Input: atkbd - correct MSC_SCAN events for force_release keys Input: cyapa - switch to using managed resources Input: lifebook - use "static inline" instead of "inline" in lifebook.h Input: touchscreen - use __maybe_unused instead of ifdef around suspend/resume Input: mouse - use __maybe_unused instead of ifdef around suspend/resume Input: misc - use __maybe_unused instead of ifdef around suspend/resume Input: cap11xx - support for irq-active-high option Input: cap11xx - add support for various cap11xx devices ...
2014-12-15Input: gpio_keys - replace timer and workqueue with delayed workqueueDmitry Torokhov1-34/+31
We do not need to roll our own implementation of delayed work now that we have proper implementation of mod_delayed_work. For interrupt-only driven buttons we retain the timer, but we rename it to release_timer to better reflect its purpose. Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-12-15Input: gpio_keys - allow separating gpio and irq in device treeDmitry Torokhov1-23/+26
This change allows specify interrupt for buttons separately form gpio, potentially allowing to form several "clusters" of buttons on different interrupts. Button defined without both gpio and irq in device tree is a hared error instead of a warning now. Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-12-14Input: gpio_keys - fix warning regarding uninitialized 'button' variableFabio Estevam1-2/+3
Commit af906faabcf91eb1 ("Input: gpio_keys - fix warning regarding uninitialized 'irq' variable") introduced the following build warning: drivers/input/keyboard/gpio_keys.c:625:16: warning: 'button' may be used uninitialized in this function [-Wmaybe-uninitialized] Move the 'button' initialization to a proper location to avoid such warning. Reported-by: Olof's autobuilder <build@lixom.net> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-12-07Input: gpio_keys - fix warning regarding uninitialized 'irq' variableDmitry Torokhov1-4/+2
Commit f2d347ff70be453e ("Input: gpio_keys - add device tree support for interrupt only keys") caused the following build warning: drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_probe': drivers/input/keyboard/gpio_keys.c:647:15: warning: 'irq' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/input/keyboard/gpio_keys.c:622:7: note: 'irq' was declared here Move button->irq initialization into proper branch and get rid of the temporary. Reported-by: Olof's autobuilder <build@lixom.net> Reported-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-12-03Input: gpio_keys - add device tree support for interrupt only keysAlexander Stein1-14/+20
This features already exists for board config setups. Add support for device tree based systems. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>