summaryrefslogtreecommitdiff
path: root/drivers/input/input.c
AgeCommit message (Collapse)Author
2018-08-08Input: do not use WARN() in input_alloc_absinfo()Dmitry Torokhov
Some of fuzzers set panic_on_warn=1 so that they can handle WARN()ings the same way they handle full-blown kernel crashes. We used WARN() in input_alloc_absinfo() to get a better idea where memory allocation failed, but since then kmalloc() and friends started dumping call stack on memory allocation failures anyway, so we are not getting anything extra from WARN(). Because of the above, let's replace WARN with dev_err(). We use dev_err() instead of simply removing message and relying on kcalloc() to give us stack dump so that we'd know the instance of hardware device to which we were trying to attach input device. Reported-by: Dmitry Vyukov <dvyukov@google.com> Acked-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2018-05-15Input: replace hard coded string with __func__ in pr_err()Nick Simonov
Change hardcoded string "input_set_capability" in pr_err() function call, replace it with "%s" __func__ instead. Signed-off-by: Nick Simonov <nicksimonovv@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2018-02-11vfs: do bulk POLL* -> EPOLL* replacementLinus Torvalds
This is the mindless scripted replacement of kernel use of POLL* variables as described by Al, done by this script: for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'` for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done done with de-mangling cleanups yet to come. NOTE! On almost all architectures, the EPOLL* constants have the same values as the POLL* constants do. But they keyword here is "almost". For various bad reasons they aren't the same, and epoll() doesn't actually work quite correctly in some cases due to this on Sparc et al. The next patch from Al will sort out the final differences, and we should be all done. Scripted-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-28the rest of drivers/*: annotate ->poll() instancesAl Viro
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-11-21treewide: Remove TIMER_FUNC_TYPE and TIMER_DATA_TYPE castsKees Cook
With all callbacks converted, and the timer callback prototype switched over, the TIMER_FUNC_TYPE cast is no longer needed, so remove it. Conversion was done with the following scripts: perl -pi -e 's|\(TIMER_FUNC_TYPE\)||g' \ $(git grep TIMER_FUNC_TYPE | cut -d: -f1 | sort -u) perl -pi -e 's|\(TIMER_DATA_TYPE\)||g' \ $(git grep TIMER_DATA_TYPE | cut -d: -f1 | sort -u) The now unused macros are also dropped from include/linux/timer.h. Signed-off-by: Kees Cook <keescook@chromium.org>
2017-11-03Input: convert autorepeat timer to use timer_setup()Kees Cook
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: Kees Cook <keescook@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-10-19Input: allow matching device IDs on property bitsDmitry Torokhov
Let's allow matching input devices on their property bits, both in-kernel and when generating module aliases. Tested-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-10-19Input: factor out and export input_device_id matching codeDmitry Torokhov
Factor out and export input_match_device_id() so that modules may use it. It will be needed by joydev to blacklist accelerometers in composite devices. Tested-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-07-12Input: constify attribute_group structuresArvind Yadav
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 17755 1312 16 19083 4a8b drivers/input/input.o File size After adding 'const': text data bss dec hex filename 17947 1120 16 19083 4a8b drivers/input/input.o Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-05-10Input: switch to using sizeof(*type) when allocating memoryMarkus Elfring
Instead of specifying type explicitly, derive it from the type of pointer when allocating memory, which is considered safer practice. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-05-10Input: use seq_puts() in input_devices_seq_show()Markus Elfring
Use seq_puts() when printing a string which does not contain a data format specification. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-05-10Input: use seq_putc() in input_seq_print_bitmap()Markus Elfring
Switch to using seq_putc() when printing a single character '0'. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-02-01Input: refuse to register absolute devices without absinfoDmitry Torokhov
If device is supposed to send absolute events (i.e. EV_ABS bit is set in dev->evbit) but dev->absinfo is not allocated, then the driver has done something wrong, and we should not register such device. Otherwise we'll crash later, when driver tries to send absolute event. Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-01-24Input: constify device_type structuresBhumika Goyal
Declare device_type structures as const as they are only stored in the type field of a device structure. This field is of type const, so add const to declaration of device_type structures. File size before: text data bss dec hex filename 17184 1344 80 18608 48b0 drivers/input/input.o File size after: text data bss dec hex filename 17248 1280 80 18608 48b0 drivers/input/input.o File size before: text data bss dec hex filename 2355 384 8 2747 abb drivers/input/rmi4/rmi_bus.o File size after: text data bss dec hex filename 2483 264 8 2755 ac3 drivers/input/rmi4/rmi_bus.o Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-07-19Merge branch 'for-linus' into nextDmitry Torokhov
Sync up to bring in wacom_w8001 changes to avoid merge conflicts later.
2016-05-19Input: feed more data into entropy poolDmitry Torokhov
Commit 4369c64c79a22 ("Input: Send events one packet at a time") significantly reduced amount of entropy input core was feeding to the rest of the system, because only the very first event in the event block would be used as source of entropy. With this change we will be calling add_input_randomness() for every event that is not filtered by the input core as a duplicate. In addition, all EV_SYN events are ignored. Acked-by: Henrik Rydberg <rydberg@bitmath.org> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-03-25drivers/input: eliminate INPUT_COMPAT_TEST macroAndrew Morton
INPUT_COMPAT_TEST became much simpler after commit f4056b52845283 ("input: redefine INPUT_COMPAT_TEST as in_compat_syscall()") so we can cleanly eliminate it altogether. Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-10-13Input: improve autorepeat initializationPetri Gynther
Add new function input_enable_softrepeat() that allows drivers to initialize their own values for input_dev->rep[REP_DELAY] and input_dev->rep[REP_PERIOD], but also use the software autorepeat functionality from input.c. For example, a HID driver could do: static void xyz_input_configured(struct hid_device *hid, struct hid_input *hidinput) { input_enable_softrepeat(hidinput->input, 400, 100); } static struct hid_driver xyz_driver = { .input_configured = xyz_input_configured, } Signed-off-by: Petri Gynther <pgynther@google.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-08-07Input: do not emit unneeded EV_SYN when suspendingDmitry Torokhov
Do not emit EV_SYN/SYN_REPORT on suspend if there were no keys that are still pressed as we are suspending the device (and in all other cases when input core is forcibly releasing keys via input_dev_release_keys() call). Reviewed-by: Benson Leung <bleung@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-06-25Input: use for_each_set_bit() where appropriateAnshul Garg
Instead of iterating over all bits in a bitmap and test them individually let's siwtch to for_each_set_bit() which is more compact and is also faster. Also use bitmap_weight() when counting number of set bits. This also fixes INPUT_DO_TOGGLE() implementation as it should have used *_CNT as the upper boundary, not *_MAX. Signed-off-by: Anshul Garg <aksgarg1989@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-05-20Input: fix typo in comment to input_handler_for_each_handle()Shailendra Verma
Signed-off-by: Shailendra Verma <shailendra.capricorn@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-01-08Input: do not try to filter out events if handler is not a filterAnshul Garg
If given input handler is not a filter there is no point is iterating list of events in a packet to see if some of them need to be filtered out. Signed-off-by: Anshul Garg <anshul.g@samsung.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-01-08Input: small tweak to autorepeat handlingAnshul Garg
If a device does not support autorepeat or does not emit any key events we should not be scanning all events in a packet to decide if we should start or stop autorepeat function. Signed-off-by: Anshul Garg <anshul.g@samsung.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-12-15Input: optimize events_per_packet count calculationAnshul Garg
This patch avoids unnecessary operations while estimating events per packet for an input device when event type is not set. Signed-off-by: Anshul Garg <anshul.g@samsung.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-12-02Input: initialize input_no to -1 to avoid subtractionAniroop Mathur
Let's initializes input_no to -1 in order to avoid extra subtraction operation performed every time we allocate an input device. Signed-off-by: Aniroop Mathur <aniroop.mathur@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-10-09Input: avoid negative input device numbersRichard Leitner
Fix the format string for input device name generation to avoid negative device numbers when the id exceeds the maximum signed integer value. Signed-off-by: Richard Leitner <richard.leitner@skidata.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-10-08Input: automatically set EV_ABS bit in input_set_abs_paramsDmitry Torokhov
Let's automatically set EV_ABS bit in device's event type list when calling input_set_abs_params() so that drivers do not have to do it explicitly. These calls are never in a hot paths so we won't lose much time by setting the same bit several times. Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-07-20Input: fix defuzzing logicDmitry Torokhov
We attempt to remove noise from coordinates reported by devices in input_handle_abs_event(), unfortunately, unless we were dropping the event altogether, we were ignoring the adjusted value and were passing on the original value instead. Cc: stable@vger.kernel.org Reviewed-by: Andrew de los Reyes <adlr@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-01-23Merge branch 'next' into for-linusDmitry Torokhov
First round of input updates for 3.14.
2013-12-31Input: allocate absinfo data when setting ABS capabilityDmitry Torokhov
We need to make sure we allocate absinfo data when we are setting one of EV_ABS/ABS_XXX capabilities, otherwise we may bomb when we try to emit this event. Rested-by: Paul Cercueil <pcercuei@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2013-12-16Input: don't call input_dev_release_keys() in resumeAleksej Makarov
When waking up the platform by pressing a specific key, sending a release on that key makes it impossible to react on the event in user-space. This is fixed by moving the input_reset_device() call to resume instead. [dmitry.torokhov@gmail.com: make sure we still restore LED/sound state after resume, handle hibernation properly] Signed-off-by: Aleksej Makarov <aleksej.makarov@sonymobile.com> Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2013-11-14Merge branch 'next' into for-linusDmitry Torokhov
Merge first round of changes for 3.13 merge window.
2013-10-31Input: remove a redundant max() callKang Hu
dev->hint_events_per_packet is guaranteed to be >= packet_size. so an extra max() call is not needed. Signed-off-by: Kang Hu <hukangustc@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2013-10-06Input: move name/timer init to input_alloc_dev()David Herrmann
We want to allow drivers to call input_event() at any time after the device got allocated. This means input_event() and input_register_device() must be allowed to run in parallel. The only conflicting calls in input_register_device() are init_timer() and dev_set_name(). Both can safely be moved to device allocation and we're good to go. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2013-01-09Input: document that unregistering managed devices is not necessaryDmitry Torokhov
Apparently some users of managed input devices are confused whether input_unregister_device() is needed when working with them. Clarify this in the kernel doc for devm_input_allocate_device(): in most cases there is no need to call neither input_unregister_device() nor input_free_device() when working with managed devices. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-11-08Input: introduce managed input devices (add devres support)Dmitry Torokhov
There is a demand from driver's writers to use managed devices framework for their drivers. Unfortunately up to this moment input devices did not provide support for managed devices and that lead to mixing two styles of resource management which usually introduced more bugs, such as manually unregistering input device but relying in devres to free interrupt handler which (unless device is properly shut off) can cause ISR to reference already freed memory. This change introduces devm_input_allocate_device() that will allocate managed instance of input device so that driver writers who prefer using devm_* framework do not have to mix 2 styles. Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Reviewed-by: Tejun Heo <tj@kernel.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-10-25Input: fix sparse warning in __input_release_device()Dmitry Torokhov
This fixes the following warning: drivers/input/input.c:538:23: error: incompatible types in comparison expression (different address spaces) Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-10-08Input: extend the number of event (and other) devicesDmitry Torokhov
Extend the amount of character devices, such as eventX, mouseX and jsX, from a hard limit of 32 per input handler to about 1024 shared across all handlers. To be compatible with legacy installations input handlers will start creating char devices with minors in their legacy range, however once legacy range is exhausted they will start allocating minors from the dynamic range 256-1024. Reviewed-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-10-01Merge branch 'for-next' of git://github.com/rydberg/linux into nextDmitry Torokhov
Merge Henrik's updates to multitouch code. Even though Jiri already pulled them in I need to do it too since my changes to evdev using dynamic major would clash with them.
2012-09-19Input: Send events one packet at a timeHenrik Rydberg
On heavy event loads, such as a multitouch driver, the irqsoff latency can be as high as 250 us. By accumulating a frame worth of data before passing it on, the latency can be dramatically reduced. As a side effect, the special EV_SYN handling can be removed, since the frame is now atomic. This patch adds the events() handler callback and uses it if it exists. The latency is improved by 50 us even without the callback. Cc: Daniel Kurtz <djkurtz@chromium.org> Tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Tested-by: Ping Cheng <pingc@wacom.com> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
2012-09-19Input: Move autorepeat to the event-passing phaseHenrik Rydberg
Preparing to split event filtering and event passing, move the autorepeat function to the point where the event is actually passed. Tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Tested-by: Ping Cheng <pingc@wacom.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
2012-09-19Input: Make sure we follow all EV_KEY eventsHenrik Rydberg
For some EV_KEY types, sending a larger-than-one value causes the input state to oscillate. This patch makes sure this cannot happen, clearing up the autorepeat bypass logic in the process. Tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Tested-by: Ping Cheng <pingc@wacom.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
2012-09-19Input: Improve the events-per-packet estimateHenrik Rydberg
The events-per-packet estimate has so far been used by MT devices only. This patch adjusts the packet buffer size to also accomodate the KEY and MSC events. Keyboards normally send one or two keys at a time. MT devices normally send a number of button keys along with the MT information. The buffer size chosen here covers those cases, and matches the default buffer size in evdev. Since the input estimate is now preferred, remove the special input-mt estimate. Reviewed-and-tested-by: Ping Cheng <pingc@wacom.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
2012-09-19Input: Break out MT dataHenrik Rydberg
Move all MT-related things to a separate place. This saves some bytes for non-mt input devices, and prepares for new MT features. Reviewed-and-tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Tested-by: Ping Cheng <pingc@wacom.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
2012-08-21Input: get rid of MATCH_BIT() macroDmitry Torokhov
MATCH_BIT() is ugly and stupid, we have much nicer bitmap_subset() which does the same and does not hide control flow. Reported-by: Baodong Chen <chenbdchenbd@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-02-02Input: Use accessor for MT valuesHenrik Rydberg
The current MT accessor function does not distinguish between the MT values and the slot specification event. Add an accessor function for the values only, and use it where appropriate. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
2012-01-03switch device_get_devnode() and ->devnode() to umode_t *Al Viro
both callers of device_get_devnode() are only interested in lower 16bits and nobody tries to return anything wider than 16bit anyway. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2011-05-25Input: properly assign return value of clamp() macro.Hans Petter Selasky
[dtor@mail.ru: added mousedev changes] Signed-off-by: Hans Petter Selasky <hselasky@c2i.net> Cc: stable@kernel.org Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
2011-05-12Input: remove useless synchronize_rcu() callsEric Dumazet
There is no need to call synchronize_rcu() after a list insertion, or a NULL->ptr assignment. However, the reverse operations do need this call. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
2011-04-18Input: estimate number of events per packetJeff Brown
Calculate a default based on the number of ABS axes, REL axes, and MT slots for the device during input device registration. Signed-off-by: Jeff Brown <jeffbrown@android.com> Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>