Commit Graph

224 Commits

Author SHA1 Message Date
Benjamin Tissoires 2c98a341ed Input: fix regression when re-registering input handlers
JIRA: https://issues.redhat.com/browse/RHEL-53898
Upstream Status: since v6.12
Tested: with the hid-tools test suite and some hardware

commit 071b24b54d2d05fbf39ddbb27dee08abd1d713f3
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Sun Oct 27 22:31:15 2024 -0700

    Input: fix regression when re-registering input handlers

    Commit d469647bafd9 ("Input: simplify event handling logic") introduced
    code that would set handler->events() method to either
    input_handler_events_filter() or input_handler_events_default() or
    input_handler_events_null(), depending on the kind of input handler
    (a filter or a regular one) we are dealing with. Unfortunately this
    breaks cases when we try to re-register the same filter (as is the case
    with sysrq handler): after initial registration the handler will have 2
    event handling methods defined, and will run afoul of the check in
    input_handler_check_methods():

            input: input_handler_check_methods: only one event processing method can be defined (sysrq)
            sysrq: Failed to register input handler, error -22

    Fix this by adding handle_events() method to input_handle structure and
    setting it up when registering a new input handle according to event
    handling methods defined in associated input_handler structure, thus
    avoiding modifying the input_handler structure.

    Reported-by: "Ned T. Crigler" <crigler@gmail.com>
    Reported-by: Christian Heusel <christian@heusel.eu>
    Tested-by: "Ned T. Crigler" <crigler@gmail.com>
    Tested-by: Peter Seiderer <ps.report@gmx.net>
    Fixes: d469647bafd9 ("Input: simplify event handling logic")
    Link: https://lore.kernel.org/r/Zx2iQp6csn42PJA7@xavtug
    Cc: stable@vger.kernel.org
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-12-12 14:06:02 +01:00
Benjamin Tissoires 587d908dd8 Input: do not check number of events in input_pass_values()
JIRA: https://issues.redhat.com/browse/RHEL-53898
Upstream Status: since v6.11
Tested: with the hid-tools test suite and some hardware

commit 735877fde06304ae9d90e17102dc2b139e8d802a
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed Jul 3 14:37:54 2024 -0700

    Input: do not check number of events in input_pass_values()

    Now that the input_dev->vals array is always there we can be assured
    that input_pass_values() is always called with a non-0 number of
    events. Remove the check.

    Reviewed-by: Jeff LaBundy <jeff@labundy.com>
    Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
    Link: https://lore.kernel.org/r/20240703213756.3375978-8-dmitry.torokhov@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-12-12 14:05:37 +01:00
Benjamin Tissoires 53d853c8ba Input: preallocate memory to hold event values
JIRA: https://issues.redhat.com/browse/RHEL-53898
Upstream Status: since v6.11
Tested: with the hid-tools test suite and some hardware

commit 0cd58773520584ccb4ce1eeebd8d43f1b27bb24a
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed Jul 3 14:37:53 2024 -0700

    Input: preallocate memory to hold event values

    Preallocate memory for holding event values (input_dev->vals) so that
    there is no need to check if it was allocated or not in the event
    processing code.

    The amount of memory will be adjusted after input device has been fully
    set up upon registering device with the input core.

    Reviewed-by: Jeff LaBundy <jeff@labundy.com>
    Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
    Link: https://lore.kernel.org/r/20240703213756.3375978-7-dmitry.torokhov@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-12-12 14:05:36 +01:00
Benjamin Tissoires c7353a1809 Input: rearrange input_alloc_device() to prepare for preallocating of vals
JIRA: https://issues.redhat.com/browse/RHEL-53898
Upstream Status: since v6.11
Tested: with the hid-tools test suite and some hardware

commit 3544cf574a577d92111f0b29e6d649b7ea3210ed
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed Jul 3 14:37:52 2024 -0700

    Input: rearrange input_alloc_device() to prepare for preallocating of vals

    In preparation to have dev->vals memory pre-allocated rearrange
    code in input_alloc_device() so that it allows handling multiple
    points of failure.

    Reviewed-by: Jeff LaBundy <jeff@labundy.com>
    Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
    Link: https://lore.kernel.org/r/20240703213756.3375978-6-dmitry.torokhov@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-12-12 14:05:36 +01:00
Benjamin Tissoires dee59d7a01 Input: simplify event handling logic
JIRA: https://issues.redhat.com/browse/RHEL-53898
Upstream Status: since v6.11
Tested: with the hid-tools test suite and some hardware

commit d469647bafd9353730e0f74ec5fbefcd431c576b
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed Jul 3 14:37:51 2024 -0700

    Input: simplify event handling logic

    Streamline event handling code by providing batch implementations for
    filtering and event processing and using them in place of the main
    event handler, as needed, instead of having complex branching logic
    in the middle of the event processing code.

    Reviewed-by: Jeff LaBundy <jeff@labundy.com>
    Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
    Link: https://lore.kernel.org/r/20240703213756.3375978-5-dmitry.torokhov@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-12-12 14:05:36 +01:00
Benjamin Tissoires ea88ad6bc4 Input: make sure input handlers define only one processing method
JIRA: https://issues.redhat.com/browse/RHEL-53898
Upstream Status: since v6.11
Tested: with the hid-tools test suite and some hardware

commit a184cf98b1d4397fe7eca881da596059fea36a18
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed Jul 3 14:37:49 2024 -0700

    Input: make sure input handlers define only one processing method

    Input core expects input handlers to be either filters, or regular
    handlers, but not both. Additionally, for regular handlers it does
    not make sense to define both single event method and batch method.

    Refuse registering handler if it defines more than one method.

    Reviewed-by: Jeff LaBundy <jeff@labundy.com>
    Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
    Link: https://lore.kernel.org/r/20240703213756.3375978-3-dmitry.torokhov@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-12-12 14:05:36 +01:00
Benjamin Tissoires db4ebfed7e Input: use sysfs_emit() instead of scnprintf()
JIRA: https://issues.redhat.com/browse/RHEL-23851
Upstream Status: since v6.8
Tested: with the hid-tools test suite and some hardware

commit d4db8762dc4c364dce89901ed4690588ad310bfc
Author: ye xingchen <ye.xingchen@zte.com.cn>
Date:   Tue Dec 12 22:37:16 2023 -0800

    Input: use sysfs_emit() instead of scnprintf()

    Replace calls to scnprintf() in the methods showing device attributes
    with sysfs_emit() to simplify the code.

    Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
    Link: https://lore.kernel.org/r/202212021133398847947@zte.com.cn
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2024-06-17 14:25:51 +02:00
Benjamin Tissoires cc91a4dd87 Input: fix open count when closing inhibited device
JIRA: https://issues.redhat.com/browse/RHEL-1259
Upstream Status: since v6.4
Tested: with the hid-tools test suite and some hardware

commit 978134c4b192ed04ecf699be3e1b4d23b5d20457
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Fri May 5 11:16:07 2023 -0700

    Input: fix open count when closing inhibited device

    Because the kernel increments device's open count in input_open_device()
    even if device is inhibited, the counter should always be decremented in
    input_close_device() to keep it balanced.

    Fixes: a181616487 ("Input: Add "inhibited" property")
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Link: https://lore.kernel.org/r/ZFFz0xAdPNSL3PT7@google.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-12-11 11:36:43 +01:00
Benjamin Tissoires 5effcbaf1b Input: avoid calling input_set_abs_val() in the event handling core
JIRA: https://issues.redhat.com/browse/RHEL-1259
Upstream Status: since v6.5
Tested: with the hid-tools test suite and some hardware

commit 3516fa162a01f6611c3c129ce9529bdc720d36b7
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Tue May 2 13:16:57 2023 -0700

    Input: avoid calling input_set_abs_val() in the event handling core

    input_abs_set_val() can nominally call input_alloc_absinfo() which may
    allocate memory with GFP_KERNEL flag. This does not happen when
    input_abs_set_val() is called by the input core to set current MT slot when
    handling a new input event, but it trips certain static analyzers.

    Rearrange the code to access the relevant structures directly.

    Reported-by: Teng Qi <starmiku1207184332@gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Link: https://lore.kernel.org/r/ZFBg379uuHjf+YEM@google.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-12-11 11:36:43 +01:00
Mark Langsdorf b38322799b driver core: make struct device_type.uevent() take a const *
JIRA: https://issues.redhat.com/browse/RHEL-1023
Conflicts:
       include/linux/device.h - minor context differences
       include/linux/i3c/device.h - minor context differences

commit 162736b0d71a9630f7c99dda7cefd5600fa03d69
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Jan 11 12:30:07 2023 +0100

The uevent() callback in struct device_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Chaitanya Kulkarni <kch@nvidia.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Mark Gross <markgross@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Maximilian Luz <luzmaximilian@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: Sean Young <sean@mess.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Won Chung <wonchung@google.com>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-6-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-10-23 10:35:56 -05:00
David Arcari eeedb0472f driver core: make struct class.devnode() take a const *
Bugzilla: https://bugzilla.redhat.com/1898182
Conflicts: RHEL does not contain drivers/vdpa/vdpa_user
Omitted-fix: dcde56bb37a9 ("Fix mismerge due to devnode now taking a 'const *' device")
	     accel_devnode is not in RHEL

commit ff62b8e6588fb07bedda7423622c140c4edd66a7
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Nov 23 13:25:20 2022 +0100

    driver core: make struct class.devnode() take a const *

    The devnode() in struct class should not be modifying the device that is
    passed into it, so mark it as a const * and propagate the function
    signature changes out into all relevant subsystems that use this
    callback.

    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: Reinette Chatre <reinette.chatre@intel.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: x86@kernel.org
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Justin Sanders <justin@coraid.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Sumit Semwal <sumit.semwal@linaro.org>
    Cc: Benjamin Gaignard <benjamin.gaignard@collabora.com>
    Cc: Liam Mark <lmark@codeaurora.org>
    Cc: Laura Abbott <labbott@redhat.com>
    Cc: Brian Starkey <Brian.Starkey@arm.com>
    Cc: John Stultz <jstultz@google.com>
    Cc: "Christian König" <christian.koenig@amd.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: David Airlie <airlied@gmail.com>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: Jason Gunthorpe <jgg@ziepe.ca>
    Cc: Leon Romanovsky <leon@kernel.org>
    Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
    Cc: Sean Young <sean@mess.org>
    Cc: Frank Haverkamp <haver@linux.ibm.com>
    Cc: Jiri Slaby <jirislaby@kernel.org>
    Cc: "Michael S. Tsirkin" <mst@redhat.com>
    Cc: Jason Wang <jasowang@redhat.com>
    Cc: Alex Williamson <alex.williamson@redhat.com>
    Cc: Cornelia Huck <cohuck@redhat.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Anton Vorontsov <anton@enomsg.org>
    Cc: Colin Cross <ccross@android.com>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: Jaroslav Kysela <perex@perex.cz>
    Cc: Takashi Iwai <tiwai@suse.com>
    Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Cc: Xie Yongji <xieyongji@bytedance.com>
    Cc: Gautam Dawar <gautam.dawar@xilinx.com>
    Cc: Dan Carpenter <error27@gmail.com>
    Cc: Eli Cohen <elic@nvidia.com>
    Cc: Parav Pandit <parav@nvidia.com>
    Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
    Cc: alsa-devel@alsa-project.org
    Cc: dri-devel@lists.freedesktop.org
    Cc: kvm@vger.kernel.org
    Cc: linaro-mm-sig@lists.linaro.org
    Cc: linux-block@vger.kernel.org
    Cc: linux-input@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-media@vger.kernel.org
    Cc: linux-rdma@vger.kernel.org
    Cc: linux-scsi@vger.kernel.org
    Cc: linux-usb@vger.kernel.org
    Cc: virtualization@lists.linux-foundation.org
    Link: https://lore.kernel.org/r/20221123122523.1332370-2-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-04-28 10:02:19 -04:00
Benjamin Tissoires d010f78ac8 Input: deactivate MT slots when inhibiting or suspending devices
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122844
Upstream Status: since v6.0
Tested: with the hid-tools test suite and some hardware

commit ebfa0043c96c7c7f645d0f96159bca988c873b6d
Author: Angela Czubak <acz@semihalf.com>
Date:   Wed Jul 20 11:15:28 2022 -0700

    Input: deactivate MT slots when inhibiting or suspending devices

    When inhibiting or suspending a device we are sending release events for
    all currently held keys and buttons, however we retain active MT slot
    state, which causes issues with gesture recognition when we resume or
    uninhibit.

    Let's fix it by introducing, in addition to input_dev_release_keys(),
    nput_mt_release_slots() that will deactivate all currently active slots.

    Signed-off-by: Angela Czubak <acz@semihalf.com>
    Link: https://lore.kernel.org/r/20220718151715.1052842-3-acz@semihalf.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-01-09 15:11:47 +01:00
Benjamin Tissoires 2a8eee25d3 Input: properly queue synthetic events
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122844
Upstream Status: since v6.0
Tested: with the hid-tools test suite and some hardware

commit 59b7a5af8e8c22b20fc68eca48d7cfdc92501c1e
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed Jul 20 11:10:47 2022 -0700

    Input: properly queue synthetic events

    We should not be passing synthetic events (such as autorepeat events)
    out of order with the events coming from the hardware device, but rather
    add them to pending events and flush them all at once.

    This also fixes an issue with timestamps for key release events carrying
    stale data from the previous autorepeat event.

    Reviewed-by: Angela Czubak <acz@semihalf.com>
    Link: https://lore.kernel.org/r/YszNfq4b6MkeoCJC@google.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-01-09 15:11:47 +01:00
Benjamin Tissoires 5ee09f4fb7 Revert "Input: clear BTN_RIGHT/MIDDLE on buttonpads"
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2070873
Upstream Status: since v5.18
Tested: with the hid-tools test suite and some hardware

commit 8b188fba75195745026e11d408e4a7e94e01d701
Author: José Expósito <jose.exposito89@gmail.com>
Date:   Thu Mar 31 21:15:36 2022 -0700

    Revert "Input: clear BTN_RIGHT/MIDDLE on buttonpads"

    This reverts commit 37ef4c19b4c659926ce65a7ac709ceaefb211c40.

    The touchpad present in the Dell Precision 7550 and 7750 laptops
    reports a HID_DG_BUTTONTYPE of type MT_BUTTONTYPE_CLICKPAD. However,
    the device is not a clickpad, it is a touchpad with physical buttons.

    In order to fix this issue, a quirk for the device was introduced in
    libinput [1] [2] to disable the INPUT_PROP_BUTTONPAD property:

            [Precision 7x50 Touchpad]
            MatchBus=i2c
            MatchUdevType=touchpad
            MatchDMIModalias=dmi:*svnDellInc.:pnPrecision7?50*
            AttrInputPropDisable=INPUT_PROP_BUTTONPAD

    However, because of the change introduced in 37ef4c19b4 ("Input: clear
    BTN_RIGHT/MIDDLE on buttonpads") the BTN_RIGHT key bit is not mapped
    anymore breaking the device right click button and making impossible to
    workaround it in user space.

    In order to avoid breakage on other present or future devices, revert
    the patch causing the issue.

    Signed-off-by: José Expósito <jose.exposito89@gmail.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
    Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220321184404.20025-1-jose.exposito89@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2022-06-22 18:11:36 +02:00
Benjamin Tissoires 852475f0a3 Input: add bounds checking to input_set_capability()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2070873
Upstream Status: since v5.18
Tested: with the hid-tools test suite and some hardware

commit 409353cbe9fe48f6bc196114c442b1cff05a39bc
Author: Jeff LaBundy <jeff@labundy.com>
Date:   Sun Mar 20 21:55:27 2022 -0700

    Input: add bounds checking to input_set_capability()

    Update input_set_capability() to prevent kernel panic in case the
    event code exceeds the bitmap for the given event type.

    Suggested-by: Tomasz Moń <tomasz.mon@camlingroup.com>
    Signed-off-by: Jeff LaBundy <jeff@labundy.com>
    Reviewed-by: Tomasz Moń <tomasz.mon@camlingroup.com>
    Link: https://lore.kernel.org/r/20220320032537.545250-1-jeff@labundy.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2022-06-22 18:11:36 +02:00
Benjamin Tissoires 106ceaa322 Input: add input_copy_abs() function
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2070873
Upstream Status: since v5.18
Tested: with the hid-tools test suite and some hardware

commit cb66b9ba5cdacab5592bce31a4083fc4ac172ea5
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Mon Feb 28 22:58:28 2022 -0800

    Input: add input_copy_abs() function

    Add a new helper function to copy absinfo from one input_dev to
    another input_dev.

    This is useful to e.g. setup a pen/stylus input-device for combined
    touchscreen/pen hardware where the pen uses the same coordinates as
    the touchscreen.

    Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20220131143539.109142-2-hdegoede@redhat.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2022-06-22 18:11:35 +02:00
Benjamin Tissoires ce20e0819e Input: set EV_ABS in dev->evbit even if input_alloc_absinfo() fails
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2070873
Upstream Status: since v5.18
Tested: with the hid-tools test suite and some hardware

commit 3f9ed5c2fe36794c1b11697bbbc6c8ec82a7d3dc
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Mon Feb 28 22:57:26 2022 -0800

    Input: set EV_ABS in dev->evbit even if input_alloc_absinfo() fails

    The input core's error handling for input_alloc_absinfo() failures
    is based on ignoring the error until input_register_device() runs
    and then checks for the failure like this:

            if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) {
                    dev_err(&dev->dev, ...);
                    return -EINVAL;
            }

    This relies on EV_ABS actually getting set in dev->evbit even
    if input_alloc_absinfo() fails, change input_set_abs_params() and
    input_set_capability() to actually adhere to this.

    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20220131143539.109142-1-hdegoede@redhat.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2022-06-22 18:11:35 +02:00
Benjamin Tissoires 7f08dff28e Input: clear BTN_RIGHT/MIDDLE on buttonpads
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2070873
Upstream Status: since v5.17
Tested: with the hid-tools test suite and some hardware

commit 37ef4c19b4c659926ce65a7ac709ceaefb211c40
Author: José Expósito <jose.exposito89@gmail.com>
Date:   Tue Feb 8 09:59:16 2022 -0800

    Input: clear BTN_RIGHT/MIDDLE on buttonpads

    Buttonpads are expected to map the INPUT_PROP_BUTTONPAD property bit
    and the BTN_LEFT key bit.

    As explained in the specification, where a device has a button type
    value of 0 (click-pad) or 1 (pressure-pad) there should not be
    discrete buttons:
    https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchpad-windows-precision-touchpad-collection#device-capabilities-feature-report

    However, some drivers map the BTN_RIGHT and/or BTN_MIDDLE key bits even
    though the device is a buttonpad and therefore does not have those
    buttons.

    This behavior has forced userspace applications like libinput to
    implement different workarounds and quirks to detect buttonpads and
    offer to the user the right set of features and configuration options.
    For more information:
    https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/726

    In order to avoid this issue clear the BTN_RIGHT and BTN_MIDDLE key
    bits when the input device is register if the INPUT_PROP_BUTTONPAD
    property bit is set.

    Notice that this change will not affect udev because it does not check
    for buttons. See systemd/src/udev/udev-builtin-input_id.c.

    List of known affected hardware:

     - Chuwi AeroBook Plus
     - Chuwi Gemibook
     - Framework Laptop
     - GPD Win Max
     - Huawei MateBook 2020
     - Prestigio Smartbook 141 C2
     - Purism Librem 14v1
     - StarLite Mk II   - AMI firmware
     - StarLite Mk II   - Coreboot firmware
     - StarLite Mk III  - AMI firmware
     - StarLite Mk III  - Coreboot firmware
     - StarLabTop Mk IV - AMI firmware
     - StarLabTop Mk IV - Coreboot firmware
     - StarBook Mk V

    Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
    Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Acked-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: José Expósito <jose.exposito89@gmail.com>
    Link: https://lore.kernel.org/r/20220208174806.17183-1-jose.exposito89@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2022-06-22 18:11:35 +02:00
Patrik Fimml a181616487 Input: Add "inhibited" property
Userspace might want to implement a policy to temporarily disregard input
from certain devices, including not treating them as wakeup sources.

An example use case is a laptop, whose keyboard can be folded under the
screen to create tablet-like experience. The user then must hold the laptop
in such a way that it is difficult to avoid pressing the keyboard keys. It
is therefore desirable to temporarily disregard input from the keyboard,
until it is folded back. This obviously is a policy which should be kept
out of the kernel, but the kernel must provide suitable means to implement
such a policy.

This patch adds a sysfs interface for exactly this purpose.

To implement the said interface it adds an "inhibited" property to struct
input_dev, and effectively creates four states a device can be in: closed
uninhibited, closed inhibited, open uninhibited, open inhibited. It also
defers calling driver's ->open() and ->close() to until they are actually
needed, e.g. it makes no sense to prepare the underlying device for
generating events (->open()) if the device is inhibited.

              uninhibit
closed      <------------ closed
uninhibited ------------> inhibited
      | ^     inhibit        | ^
 1st  | |               1st  | |
 open | |               open | |
      | |                    | |
      | | last               | | last
      | | close              | | close
      v |     uninhibit      v |
open        <------------ open
uninhibited ------------> inhibited

The top inhibit/uninhibit transition happens when users == 0.
The bottom inhibit/uninhibit transition happens when users > 0.
The left open/close transition happens when !inhibited.
The right open/close transition happens when inhibited.
Due to all transitions being serialized with dev->mutex, it is impossible
to have "diagonal" transitions between closed uninhibited and open
inhibited or between open uninhibited and closed inhibited.

No new callbacks are added to drivers, because their open() and close()
serve exactly the purpose to tell the driver to start/stop providing
events to the input core. Consequently, open() and close() - if provided
- are called in both inhibit and uninhibit paths.

Signed-off-by: Patrik Fimml <patrikf@chromium.org>
Co-developed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Link: https://lore.kernel.org/r/20200608112211.12125-8-andrzej.p@collabora.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-12-02 22:10:35 -08:00
Andrzej Pietrasiewicz 39be39ceff Input: add input_device_enabled()
A helper function for drivers to decide if the device is used or not.
A lockdep check is introduced as inspecting ->users should be done under
input device's mutex.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Link: https://lore.kernel.org/r/20200608112211.12125-2-andrzej.p@collabora.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-12-02 22:10:31 -08:00
Linus Torvalds f3e69428b5 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input fixes from Dmitry Torokhov:

 - a fix to generate proper timestamps on key autorepeat events that
   were broken recently

 - a fix for Synaptics driver to only activate reduced reporting mode
   when explicitly requested

 - a new keycode for "selective screenshot" function

 - other assorted fixes

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: fix stale timestamp on key autorepeat events
  Input: move the new KEY_SELECTIVE_SCREENSHOT keycode
  Input: avoid BIT() macro usage in the serio.h UAPI header
  Input: synaptics-rmi4 - set reduced reporting mode only when requested
  Input: synaptics - enable RMI on HP Envy 13-ad105ng
  Input: allocate keycode for "Selective Screenshot" key
  Input: tm2-touchkey - add support for Coreriver TC360 variant
  dt-bindings: input: add Coreriver TC360 binding
  dt-bindings: vendor-prefixes: Add Coreriver vendor prefix
  Input: raydium_i2c_ts - fix error codes in raydium_i2c_boot_trigger()
2020-03-26 20:49:44 -07:00
Dmitry Torokhov 4134252ab7 Input: fix stale timestamp on key autorepeat events
We need to refresh timestamp when emitting key autorepeat events, otherwise
they will carry timestamp of the original key press event.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=206929
Fixes: 3b51c44bd6 ("Input: allow drivers specify timestamp for input events")
Cc: stable@vger.kernel.org
Reported-by: teika kazura <teika@gmx.com>
Tested-by: teika kazura <teika@gmx.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2020-03-26 17:05:08 -07:00
Alexey Dobriyan 97a32539b9 proc: convert everything to "struct proc_ops"
The most notable change is DEFINE_SHOW_ATTRIBUTE macro split in
seq_file.h.

Conversion rule is:

	llseek		=> proc_lseek
	unlocked_ioctl	=> proc_ioctl

	xxx		=> proc_xxx

	delete ".owner = THIS_MODULE" line

[akpm@linux-foundation.org: fix drivers/isdn/capi/kcapi_proc.c]
[sfr@canb.auug.org.au: fix kernel/sched/psi.c]
  Link: http://lkml.kernel.org/r/20200122180545.36222f50@canb.auug.org.au
Link: http://lkml.kernel.org/r/20191225172546.GB13378@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-04 03:05:26 +00:00
Dmitry Torokhov cb222aed03 Input: add safety guards to input_set_keycode()
If we happen to have a garbage in input device's keycode table with values
too big we'll end up doing clear_bit() with offset way outside of our
bitmaps, damaging other objects within an input device or even outside of
it. Let's add sanity checks to the returned old keycodes.

Reported-by: syzbot+c769968809f9359b07aa@syzkaller.appspotmail.com
Reported-by: syzbot+76f3a30e88d256644c78@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20191207212757.GA245964@dtor-ws
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-12-13 15:00:42 -08:00
Dmitry Torokhov 4370b231d1 Input: reset device timestamp on sync
We need to reset input device's timestamp on input_sync(), otherwise
drivers not using input_set_timestamp() will end up with a stale
timestamp after their clients consume first input event.

Fixes: 3b51c44bd6 ("Input: allow drivers specify timestamp for input events")
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-09-05 17:56:32 -07:00
Dmitry Torokhov e95656ea15 Input: add support for polling to input devices
Separating "normal" and "polled" input devices was a mistake, as often we
want to allow the very same device work on both interrupt-driven and
polled mode, depending on the board on which the device is used.

This introduces new APIs:

- input_setup_polling
- input_set_poll_interval
- input_set_min_poll_interval
- input_set_max_poll_interval

These new APIs allow switching an input device into polled mode with sysfs
attributes matching drivers using input_polled_dev APIs that will be
eventually removed.

Tested-by: Michal Vokáč <michal.vokac@ysoft.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-08-20 12:04:07 -07:00
Atif Niyaz 3b51c44bd6 Input: allow drivers specify timestamp for input events
Currently, evdev stamps events with timestamps acquired in evdev_events()
However, this timestamping may not be accurate in terms of measuring
when the actual event happened.

Let's allow individual drivers specify timestamp in order to provide a more
accurate sense of time for the event. It is expected that drivers will set the
timestamp in their hard interrupt routine.

Signed-off-by: Atif Niyaz <atifniyaz@google.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-07-25 11:12:20 +03:00
Thomas Gleixner d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
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-06-19 17:09:55 +02:00
Dmitry Torokhov 100294cee9 Input: do not use WARN() in input_alloc_absinfo()
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-08-08 11:23:47 -07:00
Nick Simonov 67043f41dd Input: replace hard coded string with __func__ in pr_err()
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-05-15 12:00:53 -07:00
Linus Torvalds a9a08845e9 vfs: do bulk POLL* -> EPOLL* replacement
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>
2018-02-11 14:34:03 -08:00
Al Viro afc9a42b74 the rest of drivers/*: annotate ->poll() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-11-28 11:06:58 -05:00
Kees Cook 841b86f328 treewide: Remove TIMER_FUNC_TYPE and TIMER_DATA_TYPE casts
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-21 16:35:54 -08:00
Kees Cook 4e974c1200 Input: convert autorepeat timer to use timer_setup()
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-11-03 12:45:23 -07:00
Dmitry Torokhov 8724ecb072 Input: allow matching device IDs on property bits
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-19 16:54:49 -07:00
Dmitry Torokhov 55dfce873d Input: factor out and export input_device_id matching code
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-10-19 16:53:34 -07:00
Arvind Yadav 5e895b7416 Input: constify attribute_group structures
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-07-12 14:18:26 -07:00
Markus Elfring c3f6f8612b Input: switch to using sizeof(*type) when allocating memory
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-10 14:39:34 -07:00
Markus Elfring 63c9576544 Input: use seq_puts() in input_devices_seq_show()
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-10 14:39:34 -07:00
Markus Elfring bb546136cc Input: use seq_putc() in input_seq_print_bitmap()
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-05-10 14:39:33 -07:00
Dmitry Torokhov 6ecfe51b40 Input: refuse to register absolute devices without absinfo
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-02-01 10:33:21 -08:00
Bhumika Goyal f719315b52 Input: constify device_type structures
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>
2017-01-24 12:38:49 -08:00
Dmitry Torokhov 8c57a5e7b2 Merge branch 'for-linus' into next
Sync up to bring in wacom_w8001 changes to avoid merge conflicts later.
2016-07-19 11:02:56 -07:00
Dmitry Torokhov b55eb29841 Input: feed more data into entropy pool
Commit 4369c64c79 ("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-05-19 09:35:18 -07:00
Andrew Morton b8b4ead11e drivers/input: eliminate INPUT_COMPAT_TEST macro
INPUT_COMPAT_TEST became much simpler after commit f4056b5284
("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>
2016-03-25 16:37:42 -07:00
Petri Gynther 027c71bbae Input: improve autorepeat initialization
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-10-13 23:30:31 -07:00
Dmitry Torokhov 00159f19a5 Input: do not emit unneeded EV_SYN when suspending
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-08-07 14:55:38 -07:00
Anshul Garg 3e2b03dad5 Input: use for_each_set_bit() where appropriate
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-06-25 14:44:36 -07:00
Shailendra Verma ec8beff964 Input: fix typo in comment to input_handler_for_each_handle()
Signed-off-by: Shailendra Verma <shailendra.capricorn@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-05-20 14:45:41 -07:00
Anshul Garg 2c50ad340c Input: do not try to filter out events if handler is not a filter
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-08 13:53:34 -08:00