History log of /linux-master/drivers/input/input.c
Revision Date Author Comments
# a4735d40 09-Mar-2024 Ricardo B. Marliere <ricardo@marliere.net>

Input: make input_class constant

Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the input_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240305-class_cleanup-input-v1-1-0c3d950c25db@marliere.net
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 2a992413 15-Jan-2024 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Input: remove usage of the deprecated ida_simple_xx() API

ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range() is inclusive. So a -1 has been added when needed.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/a885de14beead2cc3c1c946f192b8b178dac696a.1705349930.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# d4db8762 12-Dec-2023 ye xingchen <ye.xingchen@zte.com.cn>

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>


# 978134c4 05-May-2023 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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: a181616487db ("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>


# 3516fa16 02-May-2023 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 345c7b74 14-Jan-2023 Jonathan Cameron <Jonathan.Cameron@huawei.com>

Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP

As the new pm_sleep_ptr() macro lets the compiler see the code, but
then remove it if !CONFIG_PM_SLEEP it can be used to avoid the need
for #ifdef guards. Use that in the input core to simplify the code
a little. Note pm_sleep_ptr() has not been applied to each callback
in the ops structure because the pm_sleep_ptr() at the usage site
is sufficient.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20230114171620.42891-15-jic23@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 162736b0 10-Jan-2023 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

driver core: make struct device_type.uevent() take a const *

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>


# ff62b8e6 23-Nov-2022 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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>


# 60f07c29 07-Nov-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Input: Use kstrtobool() instead of strtobool()

strtobool() is the same as kstrtobool().
However, the latter is more used within the kernel.

In order to remove strtobool() and slightly simplify kstrtox.h, switch to
the other function name.

While at it, include the corresponding header file (<linux/kstrtox.h>)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/4311e9cb62687449f4175e2b062abcd77aada059.1667336095.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ebfa0043 20-Jul-2022 Angela Czubak <acz@semihalf.com>

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>


# 59b7a5af 20-Jul-2022 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 0a112e7c 20-Apr-2022 Changcheng Deng <deng.changcheng@zte.com.cn>

Input: remove unneeded variable in input_inhibit_device()

Remove unneeded variable used to store return value.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
Link: https://lore.kernel.org/r/20220419064255.2563333-1-deng.changcheng@zte.com.cn
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 8b188fba 31-Mar-2022 José Expósito <jose.exposito89@gmail.com>

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>


# 409353cb 20-Mar-2022 Jeff LaBundy <jeff@labundy.com>

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>


# cb66b9ba 28-Feb-2022 Hans de Goede <hdegoede@redhat.com>

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>


# 3f9ed5c2 28-Feb-2022 Hans de Goede <hdegoede@redhat.com>

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>


# 37ef4c19 08-Feb-2022 José Expósito <jose.exposito89@gmail.com>

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>


# a1816164 02-Dec-2020 Patrik Fimml <patrikf@chromium.org>

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>


# 39be39ce 04-Oct-2020 Andrzej Pietrasiewicz <andrzej.p@collabora.com>

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>


# 4134252a 25-Mar-2020 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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: 3b51c44bd693 ("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>


# 97a32539 03-Feb-2020 Alexey Dobriyan <adobriyan@gmail.com>

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>


# cb222aed 13-Dec-2019 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 4370b231 29-Aug-2019 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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: 3b51c44bd693 ("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>


# e95656ea 18-Apr-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 3b51c44b 24-Jul-2019 Atif Niyaz <atifniyaz@google.com>

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>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

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>


# 100294ce 06-Aug-2018 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 67043f41 15-May-2018 Nick Simonov <nicksimonovv@gmail.com>

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>


# a9a08845 11-Feb-2018 Linus Torvalds <torvalds@linux-foundation.org>

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>


# afc9a42b 03-Jul-2017 Al Viro <viro@zeniv.linux.org.uk>

the rest of drivers/*: annotate ->poll() instances

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 841b86f3 23-Oct-2017 Kees Cook <keescook@chromium.org>

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>


# 4e974c12 03-Nov-2017 Kees Cook <keescook@chromium.org>

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>


# 8724ecb0 09-Oct-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 55dfce87 09-Oct-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 5e895b74 10-Jul-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

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>


# c3f6f861 09-May-2017 Markus Elfring <elfring@users.sourceforge.net>

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>


# 63c95765 09-May-2017 Markus Elfring <elfring@users.sourceforge.net>

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>


# bb546136 09-May-2017 Markus Elfring <elfring@users.sourceforge.net>

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>


# 6ecfe51b 31-Jan-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# f719315b 24-Jan-2017 Bhumika Goyal <bhumirks@gmail.com>

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>


# b55eb298 23-Jan-2016 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: feed more data into entropy pool

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>


# b8b4ead1 25-Mar-2016 Andrew Morton <akpm@linux-foundation.org>

drivers/input: eliminate INPUT_COMPAT_TEST macro

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>


# 027c71bb 14-Oct-2015 Petri Gynther <pgynther@google.com>

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>


# 00159f19 06-Aug-2015 Dmitry Torokhov <dmitry.torokhov@gmail.com>

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>


# 3e2b03da 25-Jun-2015 Anshul Garg <aksgarg1989@gmail.com>

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>


# ec8beff9 18-May-2015 Shailendra Verma <shailendra.capricorn@gmail.com>

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>


# 2c50ad34 08-Jan-2015 Anshul Garg <aksgarg1989@gmail.com>

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>


# 5ab17145 08-Jan-2015 Anshul Garg <aksgarg1989@gmail.com>

Input: small tweak to autorepeat handling

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>


# baf332c0 13-Dec-2014 Anshul Garg <anshul.g@samsung.com>

Input: optimize events_per_packet count calculation

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>


# 9c7d66fa 02-Dec-2014 Aniroop Mathur <aniroop.mathur@gmail.com>

Input: initialize input_no to -1 to avoid subtraction

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>


# bf1d50fa 08-Oct-2014 Richard Leitner <richard.leitner@skidata.com>

Input: avoid negative input device numbers

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>


# 2c9a9cfe 08-Oct-2014 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: automatically set EV_ABS bit in input_set_abs_params

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>


# 50c5d36d 19-Jul-2014 Dmitry Torokhov <dtor@chromium.org>

Input: fix defuzzing logic

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>


# 28a2a2e1 26-Dec-2013 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: allocate absinfo data when setting ABS capability

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>


# 768d9aa5 23-Nov-2013 Aleksej Makarov <aleksej.makarov@sonymobile.com>

Input: don't call input_dev_release_keys() in resume

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>


# 95079b8a 31-Oct-2013 Kang Hu <hukangustc@gmail.com>

Input: remove a redundant max() call

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>


# a60a71b0 06-Oct-2013 David Herrmann <dh.herrmann@gmail.com>

Input: move name/timer init to input_alloc_dev()

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>


# b666263b 08-Jan-2013 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: document that unregistering managed devices is not necessary

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>


# 2be975c6 03-Nov-2012 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: introduce managed input devices (add devres support)

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>


# adc4633c 25-Oct-2012 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: fix sparse warning in __input_release_device()

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>


# 7f8d4cad 08-Oct-2012 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: extend the number of event (and other) devices

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>


# 4369c64c 15-Sep-2012 Henrik Rydberg <rydberg@euromail.se>

Input: Send events one packet at a time

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>


# 352ac4bd 10-Aug-2012 Henrik Rydberg <rydberg@euromail.se>

Input: Move autorepeat to the event-passing phase

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>


# 0672120a 10-Aug-2012 Henrik Rydberg <rydberg@euromail.se>

Input: Make sure we follow all EV_KEY events

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>


# 7c75bf99 01-Sep-2012 Henrik Rydberg <rydberg@euromail.se>

Input: Improve the events-per-packet estimate

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>


# 8d18fba2 15-Sep-2012 Henrik Rydberg <rydberg@euromail.se>

Input: Break out MT data

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>


# c0bb1f97 31-Jul-2012 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: get rid of MATCH_BIT() macro

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>


# b89529a1 12-Jan-2012 Henrik Rydberg <rydberg@euromail.se>

Input: Use accessor for MT values

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>


# 2c9ede55 23-Jul-2011 Al Viro <viro@zeniv.linux.org.uk>

switch device_get_devnode() and ->devnode() to umode_t *

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>


# 8c127f07 25-May-2011 Hans Petter Selasky <hselasky@c2i.net>

Input: properly assign return value of clamp() macro.

[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>


# 7cbbb758 11-May-2011 Eric Dumazet <eric.dumazet@gmail.com>

Input: remove useless synchronize_rcu() calls

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>


# 80b4895a 18-Apr-2011 Jeff Brown <jeffbrown@google.com>

Input: estimate number of events per packet

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>


# 9ae4345a 03-Feb-2011 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Revert "Input: do not pass injected events back to the originating handler"

This reverts commit 5fdbe44d033d059cc56c2803e6b4dbd8cb4e5e39.

Apparently there exist userspace programs that expect to be able to
"loop back" and distribute to readers events written into
/dev/input/eventX and this change made for the benefit of SysRq
handler broke them. Now that SysRq uses alternative method to suppress
filtering of the events it re-injects we can safely revert this change.

Reported-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Cc: stable@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# aebd636b 31-Jan-2011 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: switch completely over to the new versions of get/setkeycode

All users of old style get/setkeycode methids have been converted so
it is time to retire them.

Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# fcd3027a 18-Dec-2010 Henrik Rydberg <rydberg@euromail.se>

Input: fix double equality sign in uevent

Looking at the uevent stream for input devices, all properties are on
the form "A=B" except the bitmap values, which are on the form
"A==B". This bug has been around at least since 2007, and the input
uevent code has been untouched since. The recent addition of device
properties suggests this is a good time for a remedy.

Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# 85b77200 18-Dec-2010 Henrik Rydberg <rydberg@euromail.se>

Input: introduce device properties

Today, userspace sets up an input device based on the data it emits.
This is not always enough; a tablet and a touchscreen may emit exactly
the same data, for instance, but the former should be set up with a
pointer whereas the latter does not need to. Recently, a new type of
touchpad has emerged where the buttons are under the pad, which
changes logic without changing the emitted data. This patch introduces
a new ioctl, EVIOCGPROP, which enables user access to a set of device
properties useful during setup. The properties are given as a bitmap
in the same fashion as the event types, and are also made available
via sysfs, uevent and /proc/bus/input/devices.

Acked-by: Ping Cheng <pingc@wacom.com>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# 47c78e89 27-Nov-2010 Henrik Rydberg <rydberg@euromail.se>

input: mt: Break out slots handling

In preparation for common code to handle a larger set of MT slots
devices, move the slots handling over to a separate file.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# da0c4901 30-Nov-2010 Joe Perches <joe@perches.com>

Input: use pr_fmt and pr_<level>

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# de391d12 18-Nov-2010 Mattia Dongili <malattia@linux.it>

Input: fix typo in keycode validation supporting large scancodes

Check the input_keymap_entry keycode size (u32) instead of the device's
(void*) when validating that keycode value can be stored in the keymap.

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=22722

Signed-off-by: Mattia Dongili <malattia@linux.it>
Tested-by: Norbert Preining <preining@logic.at>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 451a3c24 17-Nov-2010 Arnd Bergmann <arnd@arndb.de>

BKL: remove extraneous #include <smp_lock.h>

The big kernel lock has been removed from all these files at some point,
leaving only the #include.

Remove this too as a cleanup.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 5fdbe44d 08-Nov-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: do not pass injected events back to the originating handler

Sometimes input handlers (as opposed to input devices) have a need to
inject (or re-inject) events back into input core. For example sysrq
filter may want to inject previously suppressed Alt-SysRq so that user
can take a screen print. In this case we do not want to pass such events
back to the same same handler that injected them to avoid loops.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b50b5216 03-Nov-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: export input_reset_device() for use in KGDB

KGDB, much like the resume process, needs to be able to mark all keys that
were pressed at the time we dropped into the debuggers as "released", since
it is unlikely that the keys stay pressed for the entire duration of the
debug session.

Also we need to make sure that input_reset_device() and input_dev_suspend()
only attempt to change state of currenlt opened devices since closed devices
may not be ready to accept IO requests.

Tested-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 6038f373 15-Aug-2010 Arnd Bergmann <arnd@arndb.de>

llseek: automatically add .llseek fop

All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.

The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.

New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.

The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.

Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.

Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.

===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}

@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}

@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}

@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}

@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}

@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}

@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};

@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};

@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};

@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};

@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};

// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};

@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};

// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};

// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};

// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};

@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};

// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////

@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};

@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};

@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};

@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>


# 8613e4c2 09-Sep-2010 Mauro Carvalho Chehab <mchehab@kernel.org>

Input: add support for large scancodes

Several devices use a high number of bits for scancodes. One important
group is the Remote Controllers. Some new protocols like RC-6 define a
scancode space of 64 bits.

The current EVIO[CS]GKEYCODE ioctls allow replace the scancode/keycode
translation tables, but it is limited to up to 32 bits for scancode.

Also, if userspace wants to clean the existing table, replacing it by
a new one, it needs to run a loop calling the ioctls over the entire
sparse scancode space.

To solve those problems, this patch extends the ioctls to allow drivers
handle scancodes up to 32 bytes long (the length could be extended in
the future should such need arise) and allow userspace to query and set
scancode to keycode mappings not only by scancode but also by index.

Compatibility code were also added to handle the old format of
EVIO[CS]GKEYCODE ioctls.

Folded fixes by:
- Dan Carpenter: locking fixes for the original implementation
- Jarod Wilson: fix crash when setting keycode and wiring up get/set
handlers in original implementation.
- Dmitry Torokhov: rework to consolidate old and new scancode handling,
provide options to act either by index or scancode.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 144c0f88 03-Sep-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: fix a few typos

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ba4d695a 28-Aug-2010 Henrik Rydberg <rydberg@euromail.se>

Input: MT - initialize slots to unused

For MT slots, the ABS_MT_TRACKING_ID determines whether a slot is in use,
but currently leaves initialization up to the drivers. This patch sets the
slot state to unused upon creation.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# d31b2865 02-Aug-2010 Daniel Mack <daniel@caiaq.de>

Input: dynamically allocate ABS information

As all callers are now changed to only use the input_abs_*() access
helpers, switching over to dynamically allocated ABS information is
easy. This reduces size of struct input_dev from 3152 to 1640 on
64 bit architectures.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 987a6c02 02-Aug-2010 Daniel Mack <daniel@caiaq.de>

Input: switch to input_abs_*() access functions

Change all call sites in drivers/input to not access the ABS axis
information directly anymore. Make them use the access helpers instead.

Also use input_set_abs_params() when possible.
Did some code refactoring as I was on it.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 20da92de 16-Jul-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: change input handlers to use bool when possible

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 40d007e7 16-Jul-2010 Henrik Rydberg <rydberg@euromail.se>

Input: introduce MT event slots

With the rapidly increasing number of intelligent multi-contact and
multi-user devices, the need to send digested, filtered information
from a set of different sources within the same device is imminent.
This patch adds the concept of slots to the MT protocol. The slots
enumerate a set of identified sources, such that all MT events
can be passed independently and selectively per identified source.

The protocol works like this: Instead of sending a SYN_MT_REPORT
event immediately after the contact data, one sends an ABS_MT_SLOT
event immediately before the contact data. The input core will only
emit events for slots with modified MT events. It is assumed that
the same slot is used for the duration of an initiated contact.

Acked-by: Ping Cheng <pingc@wacom.com>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Rafi Rubin <rafi@seas.upenn.edu>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# fd6cf3dd 14-Jul-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: fix signedness warning in input_set_keycode()

The dev->getkeycode() method expects unsigned argument.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 866d7d7b 01-Jul-2010 Oliver Neukum <oliver@neukum.org>

Input: release pressed keys when resuming device

As the kernel has no way to know whether a key was released
while the system was asleep, keys need to be reported released
as the system is resumed, lest autorepeat set in.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5a0e3ad6 24-Mar-2010 Tejun Heo <tj@kernel.org>

include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>


# 2e2e3b96 21-Mar-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: sparse-keymap - implement safer freeing of the keymap

Allow calling sparse_keymap_free() before unregistering input device
whithout risk of racing with EVIOCGETKEYCODE and EVIOCSETKEYCODE.
This makes life of drivers writers easier.

Acked-by: Yong Wang <yong.y.wang@intel.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 2f2177c8 09-Mar-2010 Arnd Bergmann <arnd@arndb.de>

Input: remove BKL, fix input_open_file() locking

Holding the BKL in input_open_file seems pointless because it does not
protect against updates of input_table, and all open functions from the
underlying drivers have proper mutex locking.

This makes input_open_file take the input_mutex when accessing
the table and no lock when calling into the lower function.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 58b93995 08-Mar-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: scancode in get/set_keycodes should be unsigned

The HID layer has some scan codes of the form 0xffbc0000 for logitech
devices which do not work if scancode is typed as signed int, so we need
to switch to unsigned it instead. While at it keycode being signed does
not make much sense either.

Acked-by: Márton Németh <nm127@freemail.hu>
Acked-by: Matthew Garrett <mjg@redhat.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 0b7024ac 02-Feb-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: add match() method to input hanlders

Get rid of blacklist in input handler structure and instead allow
handlers to define their own match() method to perform fine-grained
filtering of supported devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ef7995f4 30-Jan-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: implement input filters

Sometimes it is desirable to suppress certain events from reaching
input handlers and thus user space. One such example is Mac mouse
button emulation code which catches certain key presses and converts
them into button clicks as if they were emitted by a virtual mouse.
The original key press events should be completely suppressed,
otherwise user space will be confused, and while keyboard driver
does it on its own evdev is blissfully unaware of this arrangement.

This patch adds notion of 'filter' to the standard input handlers,
which may flag event as filtered thus preventing it from reaching
other input handlers. Filters don't (nor will they ever) have a
notion of priority relative to each other, input core will run all
of them first and any one of them may mark event as filtered.

This patch is inspired by similar patch by Matthew Garret but the
implementation and intended usage are quite different.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# cb6ecf6f 28-Jan-2010 Henrik Rydberg <rydberg@euromail.se>

Input: add the ABS_MT_PRESSURE event

For pressure-based multi-touch devices, a direct way to send sensor
intensity data per finger is needed. This patch adds the ABS_MT_PRESSURE
event to the MT protocol.

Requested-by: Yoonyoung Shim <jy0922.shim@samsung.com>
Requested-by: Mika Kuoppala <mika.kuoppala@nokia.com>
Requested-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 15e184af 11-Jan-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: add compat support for sysfs and /proc capabilities output

Input core displays capabilities bitmasks in form of one or more longs printed
in hex form and separated by spaces. Unfortunately it does not work well
for 32-bit applications running on 64-bit kernels since applications expect
that number is "worth" only 32 bits when kernel advances by 64 bits.

Fix that by ensuring that output produced for compat tasks uses 32-bit units.

Reported-and-tested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 92a3a587 05-Jan-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: cleanse capabilities bits before registering device

To avoid showing garbage in capability bits, zero out bitmasks absent
from dev->evbit in case driver inadvertently leaves some garbage there.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 4f93df40 05-Jan-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: automatically reset KEY_RESERVED bit for all input devices

KEY_RESERVED is not supposed to be reported to userspace but rather to
mark unused entries in keymaps.

Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# df2d4637 11-Dec-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: document use of input_event() function

Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 66d2a595 01-Dec-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: keyboard - fix lack of locking when traversing handler->h_list

Keyboard handler should not attempt to traverse handler->h_list on
its own, without any locking, otherwise it races with registering
and unregistering of input handles which leads to crashes.

Introduce input_handler_for_each_handle() helper that allows safely
iterate over all handles attached to a particular handler and switch
keyboard handler to use it.

Reported-by: Jim Paradis <jparadis@redhat.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 3cc96351 13-Nov-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: force LED reset on resume

We should be sending EV_LED event down to drivers upon resume even in cases
when in-kernel state of the LED is off since device could come up with some
leds turned on.

Reported-and-tested-by: Mikko Vinni <mmvinni@yahoo.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1572ca2a 14-Oct-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: fix locking issue in /proc/bus/input/ handlers

input_devices_seq_start() uses mutex_lock_interruptible() to acquire
the input_mutex, but doesn't properly handle the situation when the
call fails (for example due to interrupt). Instead of returning NULL
(which indicates that there is no more data) we should return
ERR_PTR()-encoded error.

We also need explicit flag indicating whether input_mutex was acquired
since input_devices_seq_stop() is called whether input_devices_seq_start()
was successful or not.

The same applies to input_handlers_seq_start().

Reported-by: iceberg <strakh@ispras.ru>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a99bbaf5 04-Oct-2009 Alexey Dobriyan <adobriyan@gmail.com>

headers: remove sched.h from poll.h

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 1c4115e5 01-Oct-2009 Andrew Morton <akpm@linux-foundation.org>

drivers/input/input.c: fix CONFIG_PM=n warning

drivers/input/input.c:1277: warning: 'input_dev_reset' defined but not used

Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# e454cea2 18-Sep-2009 Kay Sievers <kay.sievers@vrfy.org>

Driver-Core: extend devnode callbacks to provide permissions

This allows subsytems to provide devtmpfs with non-default permissions
for the device node. Instead of the default mode of 0600, null, zero,
random, urandom, full, tty, ptmx now have a mode of 0666, which allows
non-privileged processes to access standard device nodes in case no
other userspace process applies the expected permissions.

This also fixes a wrong assignment in pktcdvd and a checkpatch.pl complain.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ffd0db97 16-Sep-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: add generic suspend and resume for input devices

Automatically turn off leds and sound effects as part of suspend
process and restore led state, sounds and repeat rate at resume.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a4dbd674 24-Jun-2009 David Brownell <dbrownell@users.sourceforge.net>

driver model: constify attribute groups

Let attribute group vectors be declared "const". We'd
like to let most attribute metadata live in read-only
sections... this is a start.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# aa5ed63e 30-Apr-2009 Kay Sievers <kay.sievers@vrfy.org>

Driver Core: input: add nodename for input drivers

This adds support to the input core to report the proper device name to
userspace for their devices.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# df391e0e 23-May-2009 Henrik Rydberg <rydberg@euromail.se>

Input: multitouch - add tracking ID to the protocol

There are a few multi-touch devices that support finger tracking
well in hardware, Stantum being the prime example. By exposing the
tracking ID in the MT protocol, evdev bandwidth and cpu usage in
user space can be reduced.

This patch adds the ABS_MT_TRACKING_ID to the MT protocol.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Tested-by: Stéphane Chatty <chatty@enac.fr>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5e5ee686 28-Apr-2009 Henrik Rydberg <rydberg@euromail.se>

Input: add detailed multi-touch finger data report protocol

In order to utilize the full power of the new multi-touch devices, a
way to report detailed finger data to user space is needed. This patch
adds a multi-touch (MT) protocol which allows drivers to report details
for an arbitrary number of fingers.

The driver sends a SYN_MT_REPORT event via the input_mt_sync() function
when a complete finger has been reported.

In order to stay compatible with existing applications, the data
reported in a finger packet must not be recognized as single-touch
events. In addition, all finger data must bypass input filtering,
since subsequent events of the same type refer to different fingers.

A set of ABS_MT events with the desired properties are defined. The
events are divided into categories, to allow for partial implementation.
The minimum set consists of ABS_MT_TOUCH_MAJOR, ABS_MT_POSITION_X and
ABS_MT_POSITION_Y, which allows for multiple fingers to be tracked.
If the device supports it, the ABS_MT_WIDTH_MAJOR may be used to provide
the size of the approaching finger. Anisotropy and direction may be
specified with ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MINOR and
ABS_MT_ORIENTATION. Devices with more granular information may specify
general shapes as blobs, i.e., as a sequence of rectangular shapes
grouped together by a ABS_MT_BLOB_ID. Finally, the ABS_MT_TOOL_TYPE
may be used to specify whether the touching tool is a finger or a pen.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 61994a61 28-Apr-2009 Henrik Rydberg <rydberg@euromail.se>

Input: allow certain EV_ABS events to bypass all filtering

With the upcoming multi-touch interface as an example, there is
a need to make certain that all reported events actually get passed
to the event handler. This patch equips the input core with the
ability to bypass all filtering for certain EV_ABS events.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b79e83bd 11-Apr-2009 Arjan van de Ven <arjan@infradead.org>

Input: remove unnecessary synchronize_rcu() call

There is no need to issue serialize_rcu() after adding a new handle
to the list of handles associated with the device because new events
will "see" the new handle in the list immediately. Remove it so we
can boot a little bit faster.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 99b76233 25-Mar-2009 Alexey Dobriyan <adobriyan@gmail.com>

proc 2/2: remove struct proc_dir_entry::owner

Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy
as correctly noted at bug #12454. Someone can lookup entry with NULL
->owner, thus not pinning enything, and release it later resulting
in module refcount underflow.

We can keep ->owner and supply it at registration time like ->proc_fops
and ->data.

But this leaves ->owner as easy-manipulative field (just one C assignment)
and somebody will forget to unpin previous/pin current module when
switching ->owner. ->proc_fops is declared as "const" which should give
some thoughts.

->read_proc/->write_proc were just fixed to not require ->owner for
protection.

rmmod'ed directories will be empty and return "." and ".." -- no harm.
And directories with tricky enough readdir and lookup shouldn't be modular.
We definitely don't want such modular code.

Removing ->owner will also make PDE smaller.

So, let's nuke it.

Kudos to Jeff Layton for reminding about this, let's say, oversight.

http://bugzilla.kernel.org/show_bug.cgi?id=12454

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>


# fa886612 04-Mar-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: fix polling of /proc/bus/input/devices

Tested-by: Alessio Sangalli <alesan@manoweb.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# e7b5c1ef 30-Jan-2009 Johannes Berg <johannes@sipsolutions.net>

Input: stop autorepeat timer on key release

Whenever you press and then release a key, the CPU wakes up
three times:
* press
* release
* autorepeat timer exactly 250ms after press

The autorepeat timer has nothing to do, obviously, since you already
have released the key, so stop it on key release.

[dtor@mail.ru: This changes autorepeat behavior a bit since we now stop
autorepeat even if key that is being released is not the one that is
being auto-repeated, but I believe the new behavior is better.]

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a6c2490f 29-Oct-2008 Kay Sievers <kay.sievers@vrfy.org>

Input: struct device - replace bus_id with dev_name(), dev_set_name()

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# c9812282 01-Jun-2008 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: don't reset sync flag when ignoring event

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 2edbf853 15-May-2008 Jonathan Corbet <corbet@lwn.net>

Input: cdev lock_kernel() pushdown

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# c7705f344 29-Apr-2008 Denis V. Lunev <den@openvz.org>

drivers: use non-racy method for proc entries creation (2)

Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Peter Osterlund <petero2@telia.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Neil Brown <neilb@suse.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 9c37066d 29-Apr-2008 Alexey Dobriyan <adobriyan@gmail.com>

proc: remove proc_bus

Remove proc_bus export and variable itself. Using pathnames works fine
and is slightly more understandable and greppable.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# cec69c37 30-Jan-2008 Jan Engelhardt <jengelh@computergmbh.de>

Input: constify function pointer tables (seq_operations)

Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 0c1efd36 20-Jan-2008 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: remove cdev from input_dev structure

Cdev field was obsolete and provided only for backward compatibility
since conversion of input core from class devices to regular devices.
It is time to remove it.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# f4f37c8e 03-Nov-2007 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: Add proper locking when changing device's keymap

Take dev->event_lock to make sure that we don't race with input_event() and
also force key up event when removing a key from keymap table.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ed2fa4dd 03-Jan-2008 Richard Purdie <rpurdie@rpsys.net>

Input: pass EV_PWR events to event handlers

input_handle_event() used to pass EV_PWR events to event handlers
but no longer does so in 2.6.23. Modules to trigger power management
events based on input power events exist but rely on the EV_PWR events
being passed to the input event handlers.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 22d1c398 13-Dec-2007 Dmitry Baryshkov <dbaryshkov@gmail.com>

Input: Handle EV_PWR type of input caps in input_set_capability.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7b19ada2 19-Oct-2007 Jiri Slaby <jirislaby@kernel.org>

get rid of input BIT* duplicate defines

get rid of input BIT* duplicate defines

use newly global defined macros for input layer. Also remove includes of
input.h from non-input sources only for BIT macro definiton. Define the
macro temporarily in local manner, all those local definitons will be
removed further in this patchset (to not break bisecting).
BIT macro will be globally defined (1<<x)

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: <dtor@mail.ru>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Cc: <lenb@kernel.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Cc: <perex@suse.cz>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: <vernux@us.ibm.com>
Cc: <malattia@linux.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 82ba56c2 13-Oct-2007 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: use full RCU API

RT guys alerted me to the fact that in their tree spinlocks
are preemptible and it is better to use full RCU API
(rcu_read_lock()/rcu_read_unlock()) to be safe.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7eff2e7a 14-Aug-2007 Kay Sievers <kay.sievers@vrfy.org>

Driver core: change add_uevent_var to use a struct

This changes the uevent buffer functions to use a struct instead of a
long list of parameters. It does no longer require the caller to do the
proper buffer termination and size accounting, which is currently wrong
in some places. It fixes a known bug where parts of the uevent
environment are overwritten because of wrong index calculations.

Many thanks to Mathieu Desnoyers for finding bugs and improving the
error handling.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8006479c 29-Aug-2007 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: implement proper locking in input core

Also add some kerneldoc documentation to input.h

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ad5d972c 17-Jul-2007 Pavel Emelianov <xemul@sw.ru>

Input: switch to using seq_list_xxx helpers

This is essentially just a renaming of the existing functions
as copies of seq_list_start() and seq_list_next() already existed
in the input.c.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 9657d75c 14-Jun-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: convert from class devices to standard devices

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# e63340ae 08-May-2007 Randy Dunlap <randy.dunlap@oracle.com>

header cleaning: don't include smp_lock.h when not used

Remove includes of <linux/smp_lock.h> where it is not used/needed.
Suggested by Al Viro.

Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc,
sparc64, and arm (all 59 defconfigs).

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 534565f2 24-Apr-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: add input_set_capability() helper

Add input_set_capability() helper used to indicate that an input
device supports a certain event without need to manipulate bitmaps
directly.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 88a447a0 11-Apr-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: prepare to switching to struct device

In preparation to switching to struct device and class device
going away provide an alias to allow drivers that create devices
to use either input_dev->cdev.dev or input_dev->dev.parent to
put them into sysfs tree. The former will go away once conversion
to struct device is complete.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5b2a0826 11-Apr-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: rework handle creation code

- consolidate code for binding handlers to a device
- return error codes from handlers connect() methods back to input
core and log failures

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 54f9e36c 15-Mar-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: simplify input_free_device()

Now that sysfs attributes that were marked for deletion can't access
their devices we do not need to set name, phys and uniq to NULL.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# c8e4c772 14-Mar-2007 Marvin Raaijmakers <marvin_raaijmakers@linux-box.nl>

Input: add getkeycode and setkeycode methods

Allow drivers to implement their own get and set keycode methods. This
will allow drivers to change their keymaps without allocating huge
tables covering entire range of possible scancodes.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# cb9def4d 07-Mar-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: let driver core create class device attribute groups

Rely on device core to create attribute groups for input devices
instead of open-coding it.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 15e03ae8 07-Mar-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: export 'uniq' in /proc/bus/input/devices

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1efa770f 17-Feb-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: do not lock device when showing name, phys and uniq

Now that sysfs attributes return -ENODEV once driver requests their
removal we do not need to handle scenario when data is deleted from
under our feet and can simplify the code.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# cd354f1a 14-Feb-2007 Tim Schmielau <tim@physik3.uni-rostock.de>

[PATCH] remove many unneeded #includes of sched.h

After Al Viro (finally) succeeded in removing the sched.h #include in module.h
recently, it makes sense again to remove other superfluous sched.h includes.
There are quite a lot of files which include it but don't actually need
anything defined in there. Presumably these includes were once needed for
macros that used to live in sched.h, but moved to other header files in the
course of cleaning it up.

To ease the pain, this time I did not fiddle with any header files and only
removed #includes from .c-files, which tend to cause less trouble.

Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha,
arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig,
allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all
configs in arch/arm/configs on arm. I also checked that no new warnings were
introduced by the patch (actually, some warnings are removed that were emitted
by unnecessarily included header files).

Signed-off-by: Tim Schmielau <tim@physik3.uni-rostock.de>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 2b8693c0 12-Feb-2007 Arjan van de Ven <arjan@linux.intel.com>

[PATCH] mark struct file_operations const 3

Many struct file_operations in the kernel can be "const". Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data. In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 1447190e 02-Nov-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: add comments to input_{allocate|free}_device()

Hopefully this will stop people from using input_free_device()
incorrectly.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 4263cf0f 13-Sep-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: make input_register_handler() return error codes

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 68c2a160 13-Sep-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: remove cruft that was needed for transition to sysfs

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 655816e4 13-Sep-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: fix input module refcounting

Now that input_free_device is basically an alias for input_put_device
we need to acquire a reference to input module right when we allocate
device because input_dev_release releases reference to input module
unconditionally.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 66e66118 13-Sep-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: constify input core

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 6d2750c1 10-Sep-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: send key up events at disconnect

Emit key up events for all pressed keys/buttons when disconnecting
an input device. Cures "stuck" enter key effect when unloading
keyboard module.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 509ca1a9 18-Jul-2006 Anssi Hannula <anssi.hannula@gmail.com>

Input: implement new force feedback interface

Implement a new force feedback interface, in which all non-driver-specific
operations are separated to a common module. This includes handling effect
type validations, locking, etc.

The effects are now file descriptor specific instead of the previous strange
half-process half-fd specific behaviour. The effect memory of devices is not
emptied if the root user opens and closes the device while another user is
using effects. This is a minor change and most likely no force feedback
aware programs are affected by this negatively.

Otherwise the userspace interface is left unaltered.

Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b6d786db 18-Jul-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: add missing handler->start() call

The start() method need to be called every time we create
a new handle. This includes not only registering new devices
but also when registering new handlers.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a2b2ed2c 14-Jul-2006 Andrew Morton <akpm@osdl.org>

Input: fix list iteration in input_release_device()

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 0e739d28 05-Jul-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: introduce input_inject_event() function

Create input_inject_event() function which is to be used by input
handlers as opposed to input_event() which is reserved for drivers
implementing input devices. The difference is that if device is
"grabbed" by some process input_inject_event() will ignore events
unless sent from the handle that is currently owns the device.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# c7e8dc6e 05-Jul-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: add start() method to input handlers

The new start() method is called immediately after connect() and also
when "grabbed" device is released by its owner. This will allow input
handlers to re-synchronize state of once-grabbed device with the rest
of devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# e9c8862f 05-Jul-2006 Dmitry Torokhov <dtor@insightbb.com>

Input: remove accept method from input_dev

This method used to enforce exclusive access to iforce devices,
but presenlty there are no known users of this method.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# e7374e48 27-Jun-2006 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: fix resetting name, phys and uniq when unregistering device

It should be done before calling class_device_unregister() because
it will destroy the device and free memory if there are no other
references to the device.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# ca56fe07 25-Jun-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: rearrange exports

New style is to mark symbol as exported right after its definition.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1e0afb28 25-Jun-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: fix formatting to better follow CodingStyle

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# f60d2b11 25-Jun-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: reset name, phys and uniq when unregistering

Name, phys and uniq are quite often constant strings in moules implementing
particular input device. If a module unregisters input device and then gets
unloaded, the device could still be present in memory (pinned via sysfs),
but aforementioned members would point to some random memory. Set them all
to NULL when unregistering so sysfs handlers won't try dereferencing them.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 8a3cf456 25-Jun-2006 Richard Purdie <rpurdie@rpsys.net>

Input: return correct size when reading modalias attribute

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 8fdc1948 28-Apr-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: make EVIOCGSND return meaningful data

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ddc5d341 25-Apr-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: move input_device_id to mod_devicetable.h

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ac648a6a 01-Apr-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: make modalias code respect allowed buffer size

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 969b21cd 01-Apr-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: convert /proc handling to seq_file

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 2db66876 01-Apr-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: limit attributes' output to PAGE_SIZE

sysfs can't handle more than PAGE_SIZE data coming from attributes'
show() methods; make sure we respect this limit.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 99ac48f5 28-Mar-2006 Arjan van de Ven <arjan@infradead.org>

[PATCH] mark f_ops const in the inode

Mark the f_ops members of inodes as const, as well as fix the
ripple-through this causes by places that copy this f_ops and then "do
stuff" with it.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# e676c232 18-Feb-2006 Jes Sorensen <jes@sgi.com>

Input: input core - semaphore to mutex conversion

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# bd37e5a9 05-Jan-2006 Kay Sievers <kay.sievers@suse.de>

[PATCH] INPUT: add MODALIAS to the event environment

input: add MODALIAS to the event environment

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e2bd470e 09-Jan-2006 Arjan van de Ven <arjan@infradead.org>

Input: prepare for f_ops constness

Avoid doing assignments to a live ->fops so it can be marked as 'const'.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1d8f430c 07-Dec-2005 Rusty Russell <rusty@rustcorp.com.au>

[PATCH] Input: add modalias support

Here's the patch for modalias support for input classes. It uses
comma-separated numbers, and doesn't describe all the potential keys (no
module currently cares, and that would make the strings huge). The
changes to input.h are to move the definitions needed by file2alias
outside __KERNEL__. I chose not to move those definitions to
mod_devicetable.h, because there are so many that it might break compile
of something else in the kernel.

The rest is fairly straightforward.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
CC: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 312c004d 16-Nov-2005 Kay Sievers <kay.sievers@suse.de>

[PATCH] driver core: replace "hotplug" by "uevent"

Leave the overloaded "hotplug" word to susbsystems which are handling
real devices. The driver core does not "plug" anything, it just exports
the state to userspace and generates events.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0296b228 10-Nov-2005 Kay Sievers <kay.sievers@suse.de>

[PATCH] remove CONFIG_KOBJECT_UEVENT option

It makes zero sense to have hotplug, but not the netlink
events enabled today. Remove this option and merge the
kobject_uevent.h header into the kobject.h header file.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# bd0ef235 19-Nov-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: handle failures in input_register_device()

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 08de1f04 08-Nov-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] Input: fix 'uniq' reporting in hotplug handler

Input: fix 'uniq' reporting in hotplug handler

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 47610602 02-Nov-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: fix input device deregistration

Remove main attribute group (name, phys, uniq) when unregistering
input devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5f945489 02-Nov-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: do not register statically allocated devices

Do not register statically allocated input devices to prevent
OOPS when attaching input interfaces since it requires class
device to be properly initialized.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 995fc4df 30-Oct-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: fix input_dev registration message

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a7fadbe1 15-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] input core: remove custom-made hotplug handler

Input: remove custom-made hotplug handler

Now that all input devices are registered with sysfs we can remove
old custom-made hotplug handler and crate a standard one.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ea9f240b 27-Oct-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] INPUT: rename input_dev_class to input_class to be correct.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# b0fdfebb 27-Oct-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] INPUT: remove the input_class structure, as it is unused.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 629b77a4 27-Oct-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] INPUT: Fix oops when accessing sysfs files of nested input devices

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 23d50901 27-Oct-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] INPUT: export input_dev_class so that input drivers can use it.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 10204020 27-Oct-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] INPUT: register the input class device sooner

This is needed so we can actually use the class device within the input
handlers.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 5c1e9a6a 15-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] Input: export input_dev data via sysfs attributes

Input: export various input device attributes via sysfs

The following structure is exported:

input0/
|-- name
|-- phys
|-- uniq
|-- id/{bustype|vendor|product|version}
`-- capabilities/{ev|abs|rel|key|led|msc|ff|sw}

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 051b2fea 15-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] Input: show sysfs path in /proc/bus/input/devices

Input: show sysfs path in /proc/bus/input/devices

Show that sysfs and phys path are different objects.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d19fbe8a 15-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] Input: prepare to sysfs integration

Input: prepare to sysfs integration

Add struct class_device to input_dev; add input_allocate_dev()
to dynamically allocate input devices; dynamically allocated
devices are automatically registered with sysfs.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 4f00469c 15-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] Input: kill devfs references

Input: remove references to devfs from input subsystem

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ff13f98b 24-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] Input: check switch bitmap when matching handlers

The wwitch bitmap was added to input_device_id structure and we should
check it when matching handlers and input devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 31581066 06-Sep-2005 Richard Purdie <rpurdie@rpsys.net>

[PATCH] Input: Add a new switch event type

The corgi keyboard has need of a switch event type with slightly type to the
input system as recommended by the input maintainer.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# beffbdc2 01-Jul-2005 Andrew Morton <akpm@osdl.org>

Input: cannot refer to __exit from within __init.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# f96b434d 29-Jun-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: rearrange procfs code to reduce number of #ifdefs

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1235686f 15-Mar-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] INPUT: move to use the new class code, instead of class_simple

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e334016fc 01-Jun-2005 Luke Kosewski <lkosewsk@nit.ca>

Input: do not corrupt system-wide procfs fops.

entry->proc_fops is a pointer to struct file_operations. When we
call create_proc_entry(...), it pointis to proc_file_operations,
deep in fs/proc/generic.c. By adding a 'poll' member to this struct
we effectively force the 'poll' member on every file in /proc,
which is wrong (they all fail select(...) calls).

This patch changes a copy of entry->proc_fops and reassigns it rather
than changing the original member.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 0fbf87ca 29-May-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: add semaphore and user count to input_dev structure;
serialize open and close calls and ensure that device's
open and close methods are only called when first user
opens it or last user closes it.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!