History

Merge tag 'input-for-v6.14-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov: - more conversions to the guard notation in the input core - a fix for NXP BBNSM power key driver to clean up wake IRQ after unbinding - several new vendor/device ID pairs added to xpad game controller driver - several drivers switched to using str_enable_disable and similar helpers instead of open-coding - add mapping for F23 to atkbd driver so that MS "Copilot" key shortcut works out of the box (if userspace is ready to handle it) - evbug input handler has been removed (debugging through evdev is strongly preferred to dumping all events into the kernel log). * tag 'input-for-v6.14-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (22 commits) Input: synaptics - fix crash when enabling pass-through port Input: atkbd - map F23 key to support default copilot shortcut Input: xpad - add support for Nacon Evol-X Xbox One Controller Input: xpad - add unofficial Xbox 360 wireless receiver clone Input: xpad - add support for wooting two he (arm) Input: xpad - improve name of 8BitDo controller 2dc8:3106 Input: xpad - add QH Electronics VID/PID Input: joystick - use str_off_on() helper in sw_connect() Input: Use str_enable_disable-like helpers Input: use guard notation in input core Input: poller - convert locking to guard notation Input: mt - make use of __free() cleanup facility Input: mt - convert locking to guard notation Input: ff-memless - make use of __free() cleanup facility Input: ff-memless - convert locking to guard notation Input: ff-core - make use of __free() cleanup facility Input: ff-core - convert locking to guard notation Input: remove evbug driver Input: mma8450 - add chip ID check in probe Input: bbnsm_pwrkey - add remove hook ...

Linus Torvalds committed 1 year ago

Commit 88e969f2 parents 27c0278 25768de22 files · +275 −468Browse files

Unified · Split

22 files
  1. drivers/input/Kconfig +0 −14
  2. drivers/input/Makefile +0 −1
  3. drivers/input/evbug.c +0 −100
  4. drivers/input/ff-core.c +36 −55
  5. drivers/input/ff-memless.c +6 −12
  6. drivers/input/input-mt.c +12 −22
  7. drivers/input/input-poller.c +1 −3
  8. drivers/input/input.c +131 −208
  9. drivers/input/joystick/sidewinder.c +2 −1
  10. drivers/input/joystick/xpad.c +8 −1
  11. drivers/input/keyboard/atkbd.c +1 −1
  12. drivers/input/keyboard/dlink-dir685-touchkeys.c +2 −1
  13. drivers/input/keyboard/lm8323.c +2 −1
  14. drivers/input/misc/max77693-haptic.c +2 −1
  15. drivers/input/misc/mma8450.c +15 −1
  16. drivers/input/misc/nxp-bbnsm-pwrkey.c +8 −0
  17. drivers/input/misc/regulator-haptic.c +2 −1
  18. drivers/input/mouse/elan_i2c_core.c +2 −1
  19. drivers/input/mouse/synaptics.c +42 −14
  20. drivers/input/mouse/synaptics.h +1 −0
  21. drivers/input/touchscreen/egalax_ts.c +2 −1
  22. include/linux/platform_data/keyscan-davinci.h +0 −29
drivers/input/Kconfig+0−14
@@ -152,20 +152,6 @@ config INPUT_EVDEV · 151 unmodified lines
152152 To compile this driver as a module, choose M here: the
153153 module will be called evdev.
154154
155−config INPUT_EVBUG
156− tristate "Event debugging"
157− help
158− Say Y here if you have a problem with the input subsystem and
159− want all events (keypresses, mouse movements), to be output to
160− the system log. While this is useful for debugging, it's also
161− a security threat - your keypresses include your passwords, of
162− course.
163−
164− If unsure, say N.
165−
166− To compile this driver as a module, choose M here: the
167− module will be called evbug.
168−
169155 config INPUT_KUNIT_TEST
170156 tristate "KUnit tests for Input" if !KUNIT_ALL_TESTS
171157 depends on INPUT && KUNIT
drivers/input/Makefile+0−1
@@ -18,7 +18,6 @@ obj-$(CONFIG_INPUT_LEDS) += input-leds.o · 17 unmodified lines
1818 obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
1919 obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
2020 obj-$(CONFIG_INPUT_EVDEV) += evdev.o
21−obj-$(CONFIG_INPUT_EVBUG) += evbug.o
2221
2322 obj-$(CONFIG_INPUT_KEYBOARD) += keyboard/
2423 obj-$(CONFIG_INPUT_MOUSE) += mouse/
drivers/input/evbug.c+0−100
@@ -1,100 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0-or-later
2−/*
3− * Copyright (c) 1999-2001 Vojtech Pavlik
4− */
5−
6−/*
7− * Input driver event debug module - dumps all events into syslog
8− */
9−
10−#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11−
12−#include <linux/slab.h>
13−#include <linux/module.h>
14−#include <linux/input.h>
15−#include <linux/init.h>
16−#include <linux/device.h>
17−
18−MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
19−MODULE_DESCRIPTION("Input driver event debug module");
20−MODULE_LICENSE("GPL");
21−
22−static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
23−{
24− printk(KERN_DEBUG pr_fmt("Event. Dev: %s, Type: %d, Code: %d, Value: %d\n"),
25− dev_name(&handle->dev->dev), type, code, value);
26−}
27−
28−static int evbug_connect(struct input_handler *handler, struct input_dev *dev,
29− const struct input_device_id *id)
30−{
31− struct input_handle *handle;
32− int error;
33−
34− handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
35− if (!handle)
36− return -ENOMEM;
37−
38− handle->dev = dev;
39− handle->handler = handler;
40− handle->name = "evbug";
41−
42− error = input_register_handle(handle);
43− if (error)
44− goto err_free_handle;
45−
46− error = input_open_device(handle);
47− if (error)
48− goto err_unregister_handle;
49−
50− printk(KERN_DEBUG pr_fmt("Connected device: %s (%s at %s)\n"),
51− dev_name(&dev->dev),
52− dev->name ?: "unknown",
53− dev->phys ?: "unknown");
54−
55− return 0;
56−
57− err_unregister_handle:
58− input_unregister_handle(handle);
59− err_free_handle:
60− kfree(handle);
61− return error;
62−}
63−
64−static void evbug_disconnect(struct input_handle *handle)
65−{
66− printk(KERN_DEBUG pr_fmt("Disconnected device: %s\n"),
67− dev_name(&handle->dev->dev));
68−
69− input_close_device(handle);
70− input_unregister_handle(handle);
71− kfree(handle);
72−}
73−
74−static const struct input_device_id evbug_ids[] = {
75− { .driver_info = 1 }, /* Matches all devices */
76− { }, /* Terminating zero entry */
77−};
78−
79−MODULE_DEVICE_TABLE(input, evbug_ids);
80−
81−static struct input_handler evbug_handler = {
82− .event = evbug_event,
83− .connect = evbug_connect,
84− .disconnect = evbug_disconnect,
85− .name = "evbug",
86− .id_table = evbug_ids,
87−};
88−
89−static int __init evbug_init(void)
90−{
91− return input_register_handler(&evbug_handler);
92−}
93−
94−static void __exit evbug_exit(void)
95−{
96− input_unregister_handler(&evbug_handler);
97−}
98−
99−module_init(evbug_init);
100−module_exit(evbug_exit);
drivers/input/ff-core.c+36−55
@@ -93,7 +93,7 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, · 92 unmodified lines
9393 {
9494 struct ff_device *ff = dev->ff;
9595 struct ff_effect *old;
96− int ret = 0;
96+ int error;
9797 int id;
9898
9999 if (!test_bit(EV_FF, dev->evbit))
@@ -114,22 +114,20 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, · 14 unmodified lines
114114 }
115115
116116 if (!test_bit(effect->type, ff->ffbit)) {
117− ret = compat_effect(ff, effect);
118− if (ret)
119− return ret;
117+ error = compat_effect(ff, effect);
118+ if (error)
119+ return error;
120120 }
121121
122− mutex_lock(&ff->mutex);
122+ guard(mutex)(&ff->mutex);
123123
124124 if (effect->id == -1) {
125125 for (id = 0; id < ff->max_effects; id++)
126126 if (!ff->effect_owners[id])
127127 break;
128128
129− if (id >= ff->max_effects) {
130− ret = -ENOSPC;
131− goto out;
132− }
129+ if (id >= ff->max_effects)
130+ return -ENOSPC;
133131
134132 effect->id = id;
135133 old = NULL;
@@ -137,30 +135,26 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, · 1 unmodified line
137135 } else {
138136 id = effect->id;
139137
140− ret = check_effect_access(ff, id, file);
141− if (ret)
142− goto out;
138+ error = check_effect_access(ff, id, file);
139+ if (error)
140+ return error;
143141
144142 old = &ff->effects[id];
145143
146− if (!check_effects_compatible(effect, old)) {
147− ret = -EINVAL;
148− goto out;
149− }
144+ if (!check_effects_compatible(effect, old))
145+ return -EINVAL;
150146 }
151147
152− ret = ff->upload(dev, effect, old);
153− if (ret)
154− goto out;
148+ error = ff->upload(dev, effect, old);
149+ if (error)
150+ return error;
155151
156− spin_lock_irq(&dev->event_lock);
157− ff->effects[id] = *effect;
158− ff->effect_owners[id] = file;
159− spin_unlock_irq(&dev->event_lock);
152+ scoped_guard(spinlock_irq, &dev->event_lock) {
153+ ff->effects[id] = *effect;
154+ ff->effect_owners[id] = file;
155+ }
160156
161− out:
162− mutex_unlock(&ff->mutex);
163− return ret;
157+ return 0;
164158 }
165159 EXPORT_SYMBOL_GPL(input_ff_upload);
166160
@@ -178,17 +172,16 @@ static int erase_effect(struct input_dev *dev, int effect_id, · 11 unmodified lines
178172 if (error)
179173 return error;
180174
181− spin_lock_irq(&dev->event_lock);
182− ff->playback(dev, effect_id, 0);
183− ff->effect_owners[effect_id] = NULL;
184− spin_unlock_irq(&dev->event_lock);
175+ scoped_guard(spinlock_irq, &dev->event_lock) {
176+ ff->playback(dev, effect_id, 0);
177+ ff->effect_owners[effect_id] = NULL;
178+ }
185179
186180 if (ff->erase) {
187181 error = ff->erase(dev, effect_id);
188182 if (error) {
189− spin_lock_irq(&dev->event_lock);
190− ff->effect_owners[effect_id] = file;
191− spin_unlock_irq(&dev->event_lock);
183+ scoped_guard(spinlock_irq, &dev->event_lock)
184+ ff->effect_owners[effect_id] = file;
192185
193186 return error;
194187 }
@@ -210,16 +203,12 @@ static int erase_effect(struct input_dev *dev, int effect_id, · 15 unmodified lines
210203 int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file)
211204 {
212205 struct ff_device *ff = dev->ff;
213− int ret;
214206
215207 if (!test_bit(EV_FF, dev->evbit))
216208 return -ENOSYS;
217209
218− mutex_lock(&ff->mutex);
219− ret = erase_effect(dev, effect_id, file);
220− mutex_unlock(&ff->mutex);
221−
222− return ret;
210+ guard(mutex)(&ff->mutex);
211+ return erase_effect(dev, effect_id, file);
223212 }
224213 EXPORT_SYMBOL_GPL(input_ff_erase);
225214
@@ -239,13 +228,11 @@ int input_ff_flush(struct input_dev *dev, struct file *file) · 13 unmodified lines
239228
240229 dev_dbg(&dev->dev, "flushing now\n");
241230
242− mutex_lock(&ff->mutex);
231+ guard(mutex)(&ff->mutex);
243232
244233 for (i = 0; i < ff->max_effects; i++)
245234 erase_effect(dev, i, file);
246235
247− mutex_unlock(&ff->mutex);
248−
249236 return 0;
250237 }
251238 EXPORT_SYMBOL_GPL(input_ff_flush);
@@ -303,8 +290,6 @@ EXPORT_SYMBOL_GPL(input_ff_event); · 51 unmodified lines
303290 */
304291 int input_ff_create(struct input_dev *dev, unsigned int max_effects)
305292 {
306− struct ff_device *ff;
307− size_t ff_dev_size;
308293 int i;
309294
310295 if (!max_effects) {
@@ -317,25 +302,19 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects) · 6 unmodified lines
317302 return -EINVAL;
318303 }
319304
320− ff_dev_size = struct_size(ff, effect_owners, max_effects);
321− if (ff_dev_size == SIZE_MAX) /* overflow */
322− return -EINVAL;
323−
324− ff = kzalloc(ff_dev_size, GFP_KERNEL);
305+ struct ff_device *ff __free(kfree) =
306+ kzalloc(struct_size(ff, effect_owners, max_effects),
307+ GFP_KERNEL);
325308 if (!ff)
326309 return -ENOMEM;
327310
328− ff->effects = kcalloc(max_effects, sizeof(struct ff_effect),
329− GFP_KERNEL);
330− if (!ff->effects) {
331− kfree(ff);
311+ ff->effects = kcalloc(max_effects, sizeof(*ff->effects), GFP_KERNEL);
312+ if (!ff->effects)
332313 return -ENOMEM;
333− }
334314
335315 ff->max_effects = max_effects;
336316 mutex_init(&ff->mutex);
337317
338− dev->ff = ff;
339318 dev->flush = input_ff_flush;
340319 dev->event = input_ff_event;
341320 __set_bit(EV_FF, dev->evbit);
@@ -348,6 +327,8 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects) · 6 unmodified lines
348327 if (test_bit(FF_PERIODIC, ff->ffbit))
349328 __set_bit(FF_RUMBLE, dev->ffbit);
350329
330+ dev->ff = no_free_ptr(ff);
331+
351332 return 0;
352333 }
353334 EXPORT_SYMBOL_GPL(input_ff_create);
drivers/input/ff-memless.c+6−12
@@ -401,13 +401,11 @@ static void ml_effect_timer(struct timer_list *t) · 400 unmodified lines
401401 {
402402 struct ml_device *ml = from_timer(ml, t, timer);
403403 struct input_dev *dev = ml->dev;
404− unsigned long flags;
405404
406405 pr_debug("timer: updating effects\n");
407406
408− spin_lock_irqsave(&dev->event_lock, flags);
407+ guard(spinlock_irqsave)(&dev->event_lock);
409408 ml_play_effects(ml);
410− spin_unlock_irqrestore(&dev->event_lock, flags);
411409 }
412410
413411 /*
@@ -465,7 +463,7 @@ static int ml_ff_upload(struct input_dev *dev, · 51 unmodified lines
465463 struct ml_device *ml = dev->ff->private;
466464 struct ml_effect_state *state = &ml->states[effect->id];
467465
468− spin_lock_irq(&dev->event_lock);
466+ guard(spinlock_irq)(&dev->event_lock);
469467
470468 if (test_bit(FF_EFFECT_STARTED, &state->flags)) {
471469 __clear_bit(FF_EFFECT_PLAYING, &state->flags);
@@ -477,8 +475,6 @@ static int ml_ff_upload(struct input_dev *dev, · 5 unmodified lines
477475 ml_schedule_timer(ml);
478476 }
479477
480− spin_unlock_irq(&dev->event_lock);
481−
482478 return 0;
483479 }
484480
@@ -507,12 +503,11 @@ static void ml_ff_destroy(struct ff_device *ff) · 22 unmodified lines
507503 int input_ff_create_memless(struct input_dev *dev, void *data,
508504 int (*play_effect)(struct input_dev *, void *, struct ff_effect *))
509505 {
510− struct ml_device *ml;
511506 struct ff_device *ff;
512507 int error;
513508 int i;
514509
515− ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL);
510+ struct ml_device *ml __free(kfree) = kzalloc(sizeof(*ml), GFP_KERNEL);
516511 if (!ml)
517512 return -ENOMEM;
518513
@@ -525,13 +520,10 @@ int input_ff_create_memless(struct input_dev *dev, void *data, · 6 unmodified lines
525520 set_bit(FF_GAIN, dev->ffbit);
526521
527522 error = input_ff_create(dev, FF_MEMLESS_EFFECTS);
528− if (error) {
529− kfree(ml);
523+ if (error)
530524 return error;
531− }
532525
533526 ff = dev->ff;
534− ff->private = ml;
535527 ff->upload = ml_ff_upload;
536528 ff->playback = ml_ff_playback;
537529 ff->set_gain = ml_ff_set_gain;
@@ -548,6 +540,8 @@ int input_ff_create_memless(struct input_dev *dev, void *data, · 10 unmodified lines
548540 for (i = 0; i < FF_MEMLESS_EFFECTS; i++)
549541 ml->states[i].effect = &ff->effects[i];
550542
543+ ff->private = no_free_ptr(ml);
544+
551545 return 0;
552546 }
553547 EXPORT_SYMBOL_GPL(input_ff_create_memless);
drivers/input/input-mt.c+12−22
@@ -39,20 +39,20 @@ static void copy_abs(struct input_dev *dev, unsigned int dst, unsigned int src) · 38 unmodified lines
3939 int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
4040 unsigned int flags)
4141 {
42− struct input_mt *mt = dev->mt;
43− int i;
44−
4542 if (!num_slots)
4643 return 0;
47− if (mt)
48− return mt->num_slots != num_slots ? -EINVAL : 0;
44+
45+ if (dev->mt)
46+ return dev->mt->num_slots != num_slots ? -EINVAL : 0;
47+
4948 /* Arbitrary limit for avoiding too large memory allocation. */
5049 if (num_slots > 1024)
5150 return -EINVAL;
5251
53− mt = kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL);
52+ struct input_mt *mt __free(kfree) =
53+ kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL);
5454 if (!mt)
55− goto err_mem;
55+ return -ENOMEM;
5656
5757 mt->num_slots = num_slots;
5858 mt->flags = flags;
@@ -86,21 +86,18 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, · 27 unmodified lines
8686 unsigned int n2 = num_slots * num_slots;
8787 mt->red = kcalloc(n2, sizeof(*mt->red), GFP_KERNEL);
8888 if (!mt->red)
89− goto err_mem;
89+ return -ENOMEM;
9090 }
9191
9292 /* Mark slots as 'inactive' */
93− for (i = 0; i < num_slots; i++)
93+ for (unsigned int i = 0; i < num_slots; i++)
9494 input_mt_set_value(&mt->slots[i], ABS_MT_TRACKING_ID, -1);
9595
9696 /* Mark slots as 'unused' */
9797 mt->frame = 1;
9898
99− dev->mt = mt;
99+ dev->mt = no_free_ptr(mt);
100100 return 0;
101−err_mem:
102− kfree(mt);
103− return -ENOMEM;
104101 }
105102 EXPORT_SYMBOL(input_mt_init_slots);
106103
@@ -285,14 +282,10 @@ void input_mt_drop_unused(struct input_dev *dev) · 178 unmodified lines
285282 struct input_mt *mt = dev->mt;
286283
287284 if (mt) {
288− unsigned long flags;
289−
290− spin_lock_irqsave(&dev->event_lock, flags);
285+ guard(spinlock_irqsave)(&dev->event_lock);
291286
292287 __input_mt_drop_unused(dev, mt);
293288 mt->frame++;
294−
295− spin_unlock_irqrestore(&dev->event_lock, flags);
296289 }
297290 }
298291 EXPORT_SYMBOL(input_mt_drop_unused);
@@ -339,11 +332,8 @@ void input_mt_sync_frame(struct input_dev *dev) · 40 unmodified lines
339332 return;
340333
341334 if (mt->flags & INPUT_MT_DROP_UNUSED) {
342− unsigned long flags;
343−
344− spin_lock_irqsave(&dev->event_lock, flags);
335+ guard(spinlock_irqsave)(&dev->event_lock);
345336 __input_mt_drop_unused(dev, mt);
346− spin_unlock_irqrestore(&dev->event_lock, flags);
347337 }
348338
349339 if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT))
drivers/input/input-poller.c+1−3
@@ -162,7 +162,7 @@ static ssize_t input_dev_set_poll_interval(struct device *dev, · 161 unmodified lines
162162 if (interval > poller->poll_interval_max)
163163 return -EINVAL;
164164
165− mutex_lock(&input->mutex);
165+ guard(mutex)(&input->mutex);
166166
167167 poller->poll_interval = interval;
168168
@@ -172,8 +172,6 @@ static ssize_t input_dev_set_poll_interval(struct device *dev, · 3 unmodified lines
172172 input_dev_poller_queue_work(poller);
173173 }
174174
175− mutex_unlock(&input->mutex);
176−
177175 return count;
178176 }
179177
drivers/input/input.c+131−208
@@ -115,23 +115,23 @@ static void input_pass_values(struct input_dev *dev, · 114 unmodified lines
115115
116116 lockdep_assert_held(&dev->event_lock);
117117
118− rcu_read_lock();
118+ scoped_guard(rcu) {
119+ handle = rcu_dereference(dev->grab);
120+ if (handle) {
121+ count = handle->handle_events(handle, vals, count);
122+ break;
123+ }
119124
120− handle = rcu_dereference(dev->grab);
121− if (handle) {
122− count = handle->handle_events(handle, vals, count);
123− } else {
124− list_for_each_entry_rcu(handle, &dev->h_list, d_node)
125+ list_for_each_entry_rcu(handle, &dev->h_list, d_node) {
125126 if (handle->open) {
126127 count = handle->handle_events(handle, vals,
127128 count);
128129 if (!count)
129130 break;
130131 }
132+ }
131133 }
132134
133− rcu_read_unlock();
134−
135135 /* trigger auto repeat for key events */
136136 if (test_bit(EV_REP, dev->evbit) && test_bit(EV_KEY, dev->evbit)) {
137137 for (v = vals; v != vals + count; v++) {
@@ -390,13 +390,9 @@ void input_handle_event(struct input_dev *dev, · 252 unmodified lines
390390 void input_event(struct input_dev *dev,
391391 unsigned int type, unsigned int code, int value)
392392 {
393− unsigned long flags;
394−
395393 if (is_event_supported(type, dev->evbit, EV_MAX)) {
396−
397− spin_lock_irqsave(&dev->event_lock, flags);
394+ guard(spinlock_irqsave)(&dev->event_lock);
398395 input_handle_event(dev, type, code, value);
399− spin_unlock_irqrestore(&dev->event_lock, flags);
400396 }
401397 }
402398 EXPORT_SYMBOL(input_event);
@@ -417,18 +413,15 @@ void input_inject_event(struct input_handle *handle, · 14 unmodified lines
417413 {
418414 struct input_dev *dev = handle->dev;
419415 struct input_handle *grab;
420− unsigned long flags;
421416
422417 if (is_event_supported(type, dev->evbit, EV_MAX)) {
423− spin_lock_irqsave(&dev->event_lock, flags);
418+ guard(spinlock_irqsave)(&dev->event_lock);
419+ guard(rcu)();
424420
425− rcu_read_lock();
426421 grab = rcu_dereference(dev->grab);
427422 if (!grab || grab == handle)
428423 input_handle_event(dev, type, code, value);
429− rcu_read_unlock();
430424
431− spin_unlock_irqrestore(&dev->event_lock, flags);
432425 }
433426 }
434427 EXPORT_SYMBOL(input_inject_event);
@@ -526,22 +519,15 @@ EXPORT_SYMBOL(input_copy_abs); · 91 unmodified lines
526519 int input_grab_device(struct input_handle *handle)
527520 {
528521 struct input_dev *dev = handle->dev;
529− int retval;
530522
531− retval = mutex_lock_interruptible(&dev->mutex);
532− if (retval)
533− return retval;
523+ scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) {
524+ if (dev->grab)
525+ return -EBUSY;
534526
535− if (dev->grab) {
536− retval = -EBUSY;
537− goto out;
527+ rcu_assign_pointer(dev->grab, handle);
538528 }
539529
540− rcu_assign_pointer(dev->grab, handle);
541−
542− out:
543− mutex_unlock(&dev->mutex);
544− return retval;
530+ return 0;
545531 }
546532 EXPORT_SYMBOL(input_grab_device);
547533
@@ -576,9 +562,8 @@ void input_release_device(struct input_handle *handle) · 28 unmodified lines
576562 {
577563 struct input_dev *dev = handle->dev;
578564
579− mutex_lock(&dev->mutex);
565+ guard(mutex)(&dev->mutex);
580566 __input_release_device(handle);
581− mutex_unlock(&dev->mutex);
582567 }
583568 EXPORT_SYMBOL(input_release_device);
584569
@@ -592,67 +577,57 @@ EXPORT_SYMBOL(input_release_device); · 7 unmodified lines
592577 int input_open_device(struct input_handle *handle)
593578 {
594579 struct input_dev *dev = handle->dev;
595− int retval;
596−
597− retval = mutex_lock_interruptible(&dev->mutex);
598− if (retval)
599− return retval;
600−
601− if (dev->going_away) {
602− retval = -ENODEV;
603− goto out;
604− }
580+ int error;
605581
606− handle->open++;
582+ scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) {
583+ if (dev->going_away)
584+ return -ENODEV;
607585
608− if (handle->handler->passive_observer)
609− goto out;
586+ handle->open++;
610587
611− if (dev->users++ || dev->inhibited) {
612− /*
613− * Device is already opened and/or inhibited,
614− * so we can exit immediately and report success.
615− */
616− goto out;
617− }
588+ if (handle->handler->passive_observer)
589+ return 0;
618590
619− if (dev->open) {
620− retval = dev->open(dev);
621− if (retval) {
622− dev->users--;
623− handle->open--;
591+ if (dev->users++ || dev->inhibited) {
624592 /*
625− * Make sure we are not delivering any more events
626− * through this handle
593+ * Device is already opened and/or inhibited,
594+ * so we can exit immediately and report success.
627595 */
628− synchronize_rcu();
629− goto out;
596+ return 0;
630597 }
631− }
632598
633− if (dev->poller)
634− input_dev_poller_start(dev->poller);
599+ if (dev->open) {
600+ error = dev->open(dev);
601+ if (error) {
602+ dev->users--;
603+ handle->open--;
604+ /*
605+ * Make sure we are not delivering any more
606+ * events through this handle.
607+ */
608+ synchronize_rcu();
609+ return error;
610+ }
611+ }
635612
636− out:
637− mutex_unlock(&dev->mutex);
638− return retval;
613+ if (dev->poller)
614+ input_dev_poller_start(dev->poller);
615+ }
616+
617+ return 0;
639618 }
640619 EXPORT_SYMBOL(input_open_device);
641620
642621 int input_flush_device(struct input_handle *handle, struct file *file)
643622 {
644623 struct input_dev *dev = handle->dev;
645− int retval;
646624
647− retval = mutex_lock_interruptible(&dev->mutex);
648− if (retval)
649− return retval;
650−
651− if (dev->flush)
652− retval = dev->flush(dev, file);
625+ scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) {
626+ if (dev->flush)
627+ return dev->flush(dev, file);
628+ }
653629
654− mutex_unlock(&dev->mutex);
655− return retval;
630+ return 0;
656631 }
657632 EXPORT_SYMBOL(input_flush_device);
658633
@@ -667,7 +642,7 @@ void input_close_device(struct input_handle *handle) · 8 unmodified lines
667642 {
668643 struct input_dev *dev = handle->dev;
669644
670− mutex_lock(&dev->mutex);
645+ guard(mutex)(&dev->mutex);
671646
672647 __input_release_device(handle);
673648
@@ -688,8 +663,6 @@ void input_close_device(struct input_handle *handle) · 14 unmodified lines
688663 */
689664 synchronize_rcu();
690665 }
691−
692− mutex_unlock(&dev->mutex);
693666 }
694667 EXPORT_SYMBOL(input_close_device);
695668
@@ -726,11 +699,10 @@ static void input_disconnect_device(struct input_dev *dev) · 30 unmodified lines
726699 * not to protect access to dev->going_away but rather to ensure
727700 * that there are no threads in the middle of input_open_device()
728701 */
729− mutex_lock(&dev->mutex);
730− dev->going_away = true;
731− mutex_unlock(&dev->mutex);
702+ scoped_guard(mutex, &dev->mutex)
703+ dev->going_away = true;
732704
733− spin_lock_irq(&dev->event_lock);
705+ guard(spinlock_irq)(&dev->event_lock);
734706
735707 /*
736708 * Simulate keyup events for all pressed keys so that handlers
@@ -743,8 +715,6 @@ static void input_disconnect_device(struct input_dev *dev) · 6 unmodified lines
743715
744716 list_for_each_entry(handle, &dev->h_list, d_node)
745717 handle->open = 0;
746−
747− spin_unlock_irq(&dev->event_lock);
748718 }
749719
750720 /**
@@ -901,14 +871,9 @@ static int input_default_setkeycode(struct input_dev *dev, · 150 unmodified lines
901871 */
902872 int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
903873 {
904− unsigned long flags;
905− int retval;
874+ guard(spinlock_irqsave)(&dev->event_lock);
906875
907− spin_lock_irqsave(&dev->event_lock, flags);
908− retval = dev->getkeycode(dev, ke);
909− spin_unlock_irqrestore(&dev->event_lock, flags);
910−
911− return retval;
876+ return dev->getkeycode(dev, ke);
912877 }
913878 EXPORT_SYMBOL(input_get_keycode);
914879
@@ -923,18 +888,17 @@ EXPORT_SYMBOL(input_get_keycode); · 8 unmodified lines
923888 int input_set_keycode(struct input_dev *dev,
924889 const struct input_keymap_entry *ke)
925890 {
926− unsigned long flags;
927891 unsigned int old_keycode;
928− int retval;
892+ int error;
929893
930894 if (ke->keycode > KEY_MAX)
931895 return -EINVAL;
932896
933− spin_lock_irqsave(&dev->event_lock, flags);
897+ guard(spinlock_irqsave)(&dev->event_lock);
934898
935− retval = dev->setkeycode(dev, ke, &old_keycode);
936− if (retval)
937− goto out;
899+ error = dev->setkeycode(dev, ke, &old_keycode);
900+ if (error)
901+ return error;
938902
939903 /* Make sure KEY_RESERVED did not get enabled. */
940904 __clear_bit(KEY_RESERVED, dev->keybit);
@@ -962,10 +926,7 @@ int input_set_keycode(struct input_dev *dev, · 21 unmodified lines
962926 EV_SYN, SYN_REPORT, 1);
963927 }
964928
965− out:
966− spin_unlock_irqrestore(&dev->event_lock, flags);
967−
968− return retval;
929+ return 0;
969930 }
970931 EXPORT_SYMBOL(input_set_keycode);
971932
@@ -1799,26 +1760,21 @@ static void input_dev_toggle(struct input_dev *dev, bool activate) · 827 unmodified lines
17991760 */
18001761 void input_reset_device(struct input_dev *dev)
18011762 {
1802− unsigned long flags;
1803−
1804− mutex_lock(&dev->mutex);
1805− spin_lock_irqsave(&dev->event_lock, flags);
1763+ guard(mutex)(&dev->mutex);
1764+ guard(spinlock_irqsave)(&dev->event_lock);
18061765
18071766 input_dev_toggle(dev, true);
18081767 if (input_dev_release_keys(dev))
18091768 input_handle_event(dev, EV_SYN, SYN_REPORT, 1);
1810−
1811− spin_unlock_irqrestore(&dev->event_lock, flags);
1812− mutex_unlock(&dev->mutex);
18131769 }
18141770 EXPORT_SYMBOL(input_reset_device);
18151771
18161772 static int input_inhibit_device(struct input_dev *dev)
18171773 {
1818− mutex_lock(&dev->mutex);
1774+ guard(mutex)(&dev->mutex);
18191775
18201776 if (dev->inhibited)
1821− goto out;
1777+ return 0;
18221778
18231779 if (dev->users) {
18241780 if (dev->close)
@@ -1827,54 +1783,50 @@ static int input_inhibit_device(struct input_dev *dev) · 2 unmodified lines
18271783 input_dev_poller_stop(dev->poller);
18281784 }
18291785
1830− spin_lock_irq(&dev->event_lock);
1831− input_mt_release_slots(dev);
1832− input_dev_release_keys(dev);
1833− input_handle_event(dev, EV_SYN, SYN_REPORT, 1);
1834− input_dev_toggle(dev, false);
1835− spin_unlock_irq(&dev->event_lock);
1786+ scoped_guard(spinlock_irq, &dev->event_lock) {
1787+ input_mt_release_slots(dev);
1788+ input_dev_release_keys(dev);
1789+ input_handle_event(dev, EV_SYN, SYN_REPORT, 1);
1790+ input_dev_toggle(dev, false);
1791+ }
18361792
18371793 dev->inhibited = true;
18381794
1839−out:
1840− mutex_unlock(&dev->mutex);
18411795 return 0;
18421796 }
18431797
18441798 static int input_uninhibit_device(struct input_dev *dev)
18451799 {
1846− int ret = 0;
1800+ int error;
18471801
1848− mutex_lock(&dev->mutex);
1802+ guard(mutex)(&dev->mutex);
18491803
18501804 if (!dev->inhibited)
1851− goto out;
1805+ return 0;
18521806
18531807 if (dev->users) {
18541808 if (dev->open) {
1855− ret = dev->open(dev);
1856− if (ret)
1857− goto out;
1809+ error = dev->open(dev);
1810+ if (error)
1811+ return error;
18581812 }
18591813 if (dev->poller)
18601814 input_dev_poller_start(dev->poller);
18611815 }
18621816
18631817 dev->inhibited = false;
1864− spin_lock_irq(&dev->event_lock);
1865− input_dev_toggle(dev, true);
1866− spin_unlock_irq(&dev->event_lock);
18671818
1868−out:
1869− mutex_unlock(&dev->mutex);
1870− return ret;
1819+ scoped_guard(spinlock_irq, &dev->event_lock)
1820+ input_dev_toggle(dev, true);
1821+
1822+ return 0;
18711823 }
18721824
18731825 static int input_dev_suspend(struct device *dev)
18741826 {
18751827 struct input_dev *input_dev = to_input_dev(dev);
18761828
1877− spin_lock_irq(&input_dev->event_lock);
1829+ guard(spinlock_irq)(&input_dev->event_lock);
18781830
18791831 /*
18801832 * Keys that are pressed now are unlikely to be
@@ -1886,8 +1838,6 @@ static int input_dev_suspend(struct device *dev) · 5 unmodified lines
18861838 /* Turn off LEDs and sounds, if any are active. */
18871839 input_dev_toggle(input_dev, false);
18881840
1889− spin_unlock_irq(&input_dev->event_lock);
1890−
18911841 return 0;
18921842 }
18931843
@@ -1895,13 +1845,11 @@ static int input_dev_resume(struct device *dev) · 1 unmodified line
18951845 {
18961846 struct input_dev *input_dev = to_input_dev(dev);
18971847
1898− spin_lock_irq(&input_dev->event_lock);
1848+ guard(spinlock_irq)(&input_dev->event_lock);
18991849
19001850 /* Restore state of LEDs and sounds, if any were active. */
19011851 input_dev_toggle(input_dev, true);
19021852
1903− spin_unlock_irq(&input_dev->event_lock);
1904−
19051853 return 0;
19061854 }
19071855
@@ -1909,7 +1857,7 @@ static int input_dev_freeze(struct device *dev) · 1 unmodified line
19091857 {
19101858 struct input_dev *input_dev = to_input_dev(dev);
19111859
1912− spin_lock_irq(&input_dev->event_lock);
1860+ guard(spinlock_irq)(&input_dev->event_lock);
19131861
19141862 /*
19151863 * Keys that are pressed now are unlikely to be
@@ -1918,8 +1866,6 @@ static int input_dev_freeze(struct device *dev) · 2 unmodified lines
19181866 if (input_dev_release_keys(input_dev))
19191867 input_handle_event(input_dev, EV_SYN, SYN_REPORT, 1);
19201868
1921− spin_unlock_irq(&input_dev->event_lock);
1922−
19231869 return 0;
19241870 }
19251871
@@ -1927,13 +1873,11 @@ static int input_dev_poweroff(struct device *dev) · 1 unmodified line
19271873 {
19281874 struct input_dev *input_dev = to_input_dev(dev);
19291875
1930− spin_lock_irq(&input_dev->event_lock);
1876+ guard(spinlock_irq)(&input_dev->event_lock);
19311877
19321878 /* Turn off LEDs and sounds, if any are active. */
19331879 input_dev_toggle(input_dev, false);
19341880
1935− spin_unlock_irq(&input_dev->event_lock);
1936−
19371881 return 0;
19381882 }
19391883
@@ -2274,18 +2218,16 @@ static void __input_unregister_device(struct input_dev *dev) · 334 unmodified lines
22742218
22752219 input_disconnect_device(dev);
22762220
2277− mutex_lock(&input_mutex);
2278−
2279− list_for_each_entry_safe(handle, next, &dev->h_list, d_node)
2280− handle->handler->disconnect(handle);
2281− WARN_ON(!list_empty(&dev->h_list));
2221+ scoped_guard(mutex, &input_mutex) {
2222+ list_for_each_entry_safe(handle, next, &dev->h_list, d_node)
2223+ handle->handler->disconnect(handle);
2224+ WARN_ON(!list_empty(&dev->h_list));
22822225
2283− del_timer_sync(&dev->timer);
2284− list_del_init(&dev->node);
2226+ del_timer_sync(&dev->timer);
2227+ list_del_init(&dev->node);
22852228
2286− input_wakeup_procfs_readers();
2287−
2288− mutex_unlock(&input_mutex);
2229+ input_wakeup_procfs_readers();
2230+ }
22892231
22902232 device_del(&dev->dev);
22912233 }
@@ -2308,9 +2250,8 @@ static void devm_input_device_unregister(struct device *dev, void *res) · 16 unmodified lines
23082250 static void input_repeat_key(struct timer_list *t)
23092251 {
23102252 struct input_dev *dev = from_timer(dev, t, timer);
2311− unsigned long flags;
23122253
2313− spin_lock_irqsave(&dev->event_lock, flags);
2254+ guard(spinlock_irqsave)(&dev->event_lock);
23142255
23152256 if (!dev->inhibited &&
23162257 test_bit(dev->repeat_key, dev->key) &&
@@ -2324,8 +2265,6 @@ static void input_repeat_key(struct timer_list *t) · 7 unmodified lines
23242265 mod_timer(&dev->timer, jiffies +
23252266 msecs_to_jiffies(dev->rep[REP_PERIOD]));
23262267 }
2327−
2328− spin_unlock_irqrestore(&dev->event_lock, flags);
23292268 }
23302269
23312270 /**
@@ -2370,10 +2309,10 @@ static int input_device_tune_vals(struct input_dev *dev) · 38 unmodified lines
23702309 if (!vals)
23712310 return -ENOMEM;
23722311
2373− spin_lock_irq(&dev->event_lock);
2374− dev->max_vals = max_vals;
2375− swap(dev->vals, vals);
2376− spin_unlock_irq(&dev->event_lock);
2312+ scoped_guard(spinlock_irq, &dev->event_lock) {
2313+ dev->max_vals = max_vals;
2314+ swap(dev->vals, vals);
2315+ }
23772316
23782317 /* Because of swap() above, this frees the old vals memory */
23792318 kfree(vals);
@@ -2465,18 +2404,15 @@ int input_register_device(struct input_dev *dev) · 85 unmodified lines
24652404 path ? path : "N/A");
24662405 kfree(path);
24672406
2468− error = mutex_lock_interruptible(&input_mutex);
2469− if (error)
2470− goto err_device_del;
2407+ error = -EINTR;
2408+ scoped_cond_guard(mutex_intr, goto err_device_del, &input_mutex) {
2409+ list_add_tail(&dev->node, &input_dev_list);
24712410
2472− list_add_tail(&dev->node, &input_dev_list);
2411+ list_for_each_entry(handler, &input_handler_list, node)
2412+ input_attach_handler(dev, handler);
24732413
2474− list_for_each_entry(handler, &input_handler_list, node)
2475− input_attach_handler(dev, handler);
2476−
2477− input_wakeup_procfs_readers();
2478−
2479− mutex_unlock(&input_mutex);
2414+ input_wakeup_procfs_readers();
2415+ }
24802416
24812417 if (dev->devres_managed) {
24822418 dev_dbg(dev->dev.parent, "%s: registering %s with devres.\n",
@@ -2556,20 +2492,17 @@ int input_register_handler(struct input_handler *handler) · 73 unmodified lines
25562492 if (error)
25572493 return error;
25582494
2559− INIT_LIST_HEAD(&handler->h_list);
2495+ scoped_cond_guard(mutex_intr, return -EINTR, &input_mutex) {
2496+ INIT_LIST_HEAD(&handler->h_list);
25602497
2561− error = mutex_lock_interruptible(&input_mutex);
2562− if (error)
2563− return error;
2564−
2565− list_add_tail(&handler->node, &input_handler_list);
2498+ list_add_tail(&handler->node, &input_handler_list);
25662499
2567− list_for_each_entry(dev, &input_dev_list, node)
2568− input_attach_handler(dev, handler);
2500+ list_for_each_entry(dev, &input_dev_list, node)
2501+ input_attach_handler(dev, handler);
25692502
2570− input_wakeup_procfs_readers();
2503+ input_wakeup_procfs_readers();
2504+ }
25712505
2572− mutex_unlock(&input_mutex);
25732506 return 0;
25742507 }
25752508 EXPORT_SYMBOL(input_register_handler);
@@ -2585,7 +2518,7 @@ void input_unregister_handler(struct input_handler *handler) · 9 unmodified lines
25852518 {
25862519 struct input_handle *handle, *next;
25872520
2588− mutex_lock(&input_mutex);
2521+ guard(mutex)(&input_mutex);
25892522
25902523 list_for_each_entry_safe(handle, next, &handler->h_list, h_node)
25912524 handler->disconnect(handle);
@@ -2594,8 +2527,6 @@ void input_unregister_handler(struct input_handler *handler) · 2 unmodified lines
25942527 list_del_init(&handler->node);
25952528
25962529 input_wakeup_procfs_readers();
2597−
2598− mutex_unlock(&input_mutex);
25992530 }
26002531 EXPORT_SYMBOL(input_unregister_handler);
26012532
@@ -2615,19 +2546,17 @@ int input_handler_for_each_handle(struct input_handler *handler, void *data, · 13 unmodified lines
26152546 int (*fn)(struct input_handle *, void *))
26162547 {
26172548 struct input_handle *handle;
2618− int retval = 0;
2549+ int retval;
26192550
2620− rcu_read_lock();
2551+ guard(rcu)();
26212552
26222553 list_for_each_entry_rcu(handle, &handler->h_list, h_node) {
26232554 retval = fn(handle, data);
26242555 if (retval)
2625− break;
2556+ return retval;
26262557 }
26272558
2628− rcu_read_unlock();
2629−
2630− return retval;
2559+ return 0;
26312560 }
26322561 EXPORT_SYMBOL(input_handler_for_each_handle);
26332562
@@ -2715,27 +2644,22 @@ int input_register_handle(struct input_handle *handle) · 81 unmodified lines
27152644 {
27162645 struct input_handler *handler = handle->handler;
27172646 struct input_dev *dev = handle->dev;
2718− int error;
27192647
27202648 input_handle_setup_event_handler(handle);
27212649 /*
27222650 * We take dev->mutex here to prevent race with
27232651 * input_release_device().
27242652 */
2725− error = mutex_lock_interruptible(&dev->mutex);
2726− if (error)
2727− return error;
2728−
2729− /*
2730− * Filters go to the head of the list, normal handlers
2731− * to the tail.
2732− */
2733− if (handler->filter)
2734− list_add_rcu(&handle->d_node, &dev->h_list);
2735− else
2736− list_add_tail_rcu(&handle->d_node, &dev->h_list);
2737−
2738− mutex_unlock(&dev->mutex);
2653+ scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) {
2654+ /*
2655+ * Filters go to the head of the list, normal handlers
2656+ * to the tail.
2657+ */
2658+ if (handler->filter)
2659+ list_add_rcu(&handle->d_node, &dev->h_list);
2660+ else
2661+ list_add_tail_rcu(&handle->d_node, &dev->h_list);
2662+ }
27392663
27402664 /*
27412665 * Since we are supposed to be called from ->connect()
@@ -2771,9 +2695,8 @@ void input_unregister_handle(struct input_handle *handle) · 29 unmodified lines
27712695 /*
27722696 * Take dev->mutex to prevent race with input_release_device().
27732697 */
2774− mutex_lock(&dev->mutex);
2775− list_del_rcu(&handle->d_node);
2776− mutex_unlock(&dev->mutex);
2698+ scoped_guard(mutex, &dev->mutex)
2699+ list_del_rcu(&handle->d_node);
27772700
27782701 synchronize_rcu();
27792702 }
drivers/input/joystick/sidewinder.c+2−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/input.h>
1515 #include <linux/gameport.h>
1616 #include <linux/jiffies.h>
17+#include <linux/string_choices.h>
1718
1819 #define DRIVER_DESC "Microsoft SideWinder joystick family driver"
1920
@@ -677,7 +678,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) · 657 unmodified lines
677678 case 48: /* Ambiguous */
678679 if (j == 14) { /* ID length 14*3 -> FFP */
679680 sw->type = SW_ID_FFP;
680− sprintf(comment, " [AC %s]", sw_get_bits(idbuf,38,1,3) ? "off" : "on");
681+ sprintf(comment, " [AC %s]", str_off_on(sw_get_bits(idbuf,38,1,3)));
681682 } else
682683 sw->type = SW_ID_PP;
683684 break;
drivers/input/joystick/xpad.c+8−1
@@ -150,6 +150,7 @@ static const struct xpad_device { · 149 unmodified lines
150150 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
151151 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
152152 { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
153+ { 0x045e, 0x02a9, "Xbox 360 Wireless Receiver (Unofficial)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
153154 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
154155 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
155156 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE },
@@ -305,6 +306,7 @@ static const struct xpad_device { · 149 unmodified lines
305306 { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 },
306307 { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 },
307308 { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 },
309+ { 0x1a86, 0xe310, "QH Electronics Controller", 0, XTYPE_XBOX360 },
308310 { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
309311 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
310312 { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
@@ -373,16 +375,19 @@ static const struct xpad_device { · 62 unmodified lines
373375 { 0x294b, 0x3303, "Snakebyte GAMEPAD BASE X", 0, XTYPE_XBOXONE },
374376 { 0x294b, 0x3404, "Snakebyte GAMEPAD RGB X", 0, XTYPE_XBOXONE },
375377 { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
376− { 0x2dc8, 0x3106, "8BitDo Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
378+ { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
377379 { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 },
378380 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
379381 { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 },
380382 { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 },
381383 { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 },
382384 { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 },
385+ { 0x31e3, 0x1230, "Wooting Two HE (ARM)", 0, XTYPE_XBOX360 },
383386 { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 },
384387 { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 },
385388 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
389+ { 0x3285, 0x0646, "Nacon Pro Compact", 0, XTYPE_XBOXONE },
390+ { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE },
386391 { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 },
387392 { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX },
388393 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
@@ -514,6 +519,7 @@ static const struct usb_device_id xpad_table[] = { · 125 unmodified lines
514519 XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */
515520 XPAD_XBOX360_VENDOR(0x17ef), /* Lenovo */
516521 XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */
522+ XPAD_XBOX360_VENDOR(0x1a86), /* QH Electronics */
517523 XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */
518524 XPAD_XBOX360_VENDOR(0x20d6), /* PowerA controllers */
519525 XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA controllers */
@@ -530,6 +536,7 @@ static const struct usb_device_id xpad_table[] = { · 10 unmodified lines
530536 XPAD_XBOX360_VENDOR(0x2f24), /* GameSir controllers */
531537 XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */
532538 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */
539+ XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */
533540 XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */
534541 XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */
535542 { }
drivers/input/keyboard/atkbd.c+1−1
@@ -89,7 +89,7 @@ static const unsigned short atkbd_set2_keycode[ATKBD_KEYMAP_SIZE] = { · 88 unmodified lines
8989 0, 46, 45, 32, 18, 5, 4, 95, 0, 57, 47, 33, 20, 19, 6,183,
9090 0, 49, 48, 35, 34, 21, 7,184, 0, 0, 50, 36, 22, 8, 9,185,
9191 0, 51, 37, 23, 24, 11, 10, 0, 0, 52, 53, 38, 39, 25, 12, 0,
92− 0, 89, 40, 0, 26, 13, 0, 0, 58, 54, 28, 27, 0, 43, 0, 85,
92+ 0, 89, 40, 0, 26, 13, 0,193, 58, 54, 28, 27, 0, 43, 0, 85,
9393 0, 86, 91, 90, 92, 0, 14, 94, 0, 79,124, 75, 71,121, 0, 0,
9494 82, 83, 80, 76, 77, 72, 1, 69, 87, 78, 81, 74, 55, 73, 70, 99,
9595
drivers/input/keyboard/dlink-dir685-touchkeys.c+2−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/delay.h>
1515 #include <linux/input.h>
1616 #include <linux/slab.h>
17+#include <linux/string_choices.h>
1718 #include <linux/bitops.h>
1819
1920 struct dir685_touchkeys {
@@ -48,7 +49,7 @@ static irqreturn_t dir685_tk_irq_thread(int irq, void *data) · 28 unmodified lines
4849 changed = tk->cur_key ^ key;
4950 for_each_set_bit(i, &changed, num_bits) {
5051 dev_dbg(tk->dev, "key %d is %s\n", i,
51− test_bit(i, &key) ? "down" : "up");
52+ str_down_up(test_bit(i, &key)));
5253 input_report_key(tk->input, tk->codes[i], test_bit(i, &key));
5354 }
5455
drivers/input/keyboard/lm8323.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <linux/platform_data/lm8323.h>
2222 #include <linux/pm.h>
2323 #include <linux/slab.h>
24+#include <linux/string_choices.h>
2425
2526 /* Commands to send to the chip. */
2627 #define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */
@@ -269,7 +270,7 @@ static void process_keys(struct lm8323_chip *lm) · 242 unmodified lines
269270 unsigned short keycode = lm->keymap[key];
270271
271272 dev_vdbg(&lm->client->dev, "key 0x%02x %s\n",
272− key, isdown ? "down" : "up");
273+ key, str_down_up(isdown));
273274
274275 if (lm->kp_enabled) {
275276 input_event(lm->idev, EV_MSC, MSC_SCAN, key);
drivers/input/misc/max77693-haptic.c+2−1
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/platform_device.h>
1919 #include <linux/pwm.h>
2020 #include <linux/slab.h>
21+#include <linux/string_choices.h>
2122 #include <linux/workqueue.h>
2223 #include <linux/regulator/consumer.h>
2324 #include <linux/mfd/max77693.h>
@@ -94,7 +95,7 @@ static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on) · 70 unmodified lines
9495 on << MAINCTRL1_BIASEN_SHIFT);
9596 if (error) {
9697 dev_err(haptic->dev, "failed to %s bias: %d\n",
97− on ? "enable" : "disable", error);
98+ str_enable_disable(on), error);
9899 return error;
99100 }
100101
drivers/input/misc/mma8450.c+15−1
@@ -38,6 +38,8 @@ · 37 unmodified lines
3838
3939 #define MMA8450_CTRL_REG1 0x38
4040 #define MMA8450_CTRL_REG2 0x39
41+#define MMA8450_ID 0xc6
42+#define MMA8450_WHO_AM_I 0x0f
4143
4244 static int mma8450_read(struct i2c_client *c, unsigned int off)
4345 {
@@ -148,8 +150,20 @@ static void mma8450_close(struct input_dev *input) · 104 unmodified lines
148150 */
149151 static int mma8450_probe(struct i2c_client *c)
150152 {
153+ struct i2c_adapter *adapter = c->adapter;
151154 struct input_dev *input;
152− int err;
155+ int err, client_id;
156+
157+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE |
158+ I2C_FUNC_SMBUS_BYTE_DATA))
159+ return dev_err_probe(&c->dev, -EINVAL,
160+ "I2C adapter doesn't support SMBUS BYTE");
161+
162+ client_id = i2c_smbus_read_byte_data(c, MMA8450_WHO_AM_I);
163+ if (client_id != MMA8450_ID)
164+ return dev_err_probe(&c->dev, -EINVAL,
165+ "unexpected chip ID 0x%x (vs 0x%x)\n",
166+ client_id, MMA8450_ID);
153167
154168 input = devm_input_allocate_device(&c->dev);
155169 if (!input)
drivers/input/misc/nxp-bbnsm-pwrkey.c+8−0
@@ -187,6 +187,12 @@ static int bbnsm_pwrkey_probe(struct platform_device *pdev) · 186 unmodified lines
187187 return 0;
188188 }
189189
190+static void bbnsm_pwrkey_remove(struct platform_device *pdev)
191+{
192+ dev_pm_clear_wake_irq(&pdev->dev);
193+ device_init_wakeup(&pdev->dev, false);
194+}
195+
190196 static int __maybe_unused bbnsm_pwrkey_suspend(struct device *dev)
191197 {
192198 struct platform_device *pdev = to_platform_device(dev);
@@ -223,6 +229,8 @@ static struct platform_driver bbnsm_pwrkey_driver = { · 30 unmodified lines
223229 .of_match_table = bbnsm_pwrkey_ids,
224230 },
225231 .probe = bbnsm_pwrkey_probe,
232+ .remove = bbnsm_pwrkey_remove,
233+
226234 };
227235 module_platform_driver(bbnsm_pwrkey_driver);
228236
drivers/input/misc/regulator-haptic.c+2−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/platform_device.h>
1515 #include <linux/regulator/consumer.h>
1616 #include <linux/slab.h>
17+#include <linux/string_choices.h>
1718
1819 #define MAX_MAGNITUDE_SHIFT 16
1920
@@ -44,7 +45,7 @@ static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on) · 24 unmodified lines
4445 if (error) {
4546 dev_err(haptic->dev,
4647 "failed to switch regulator %s: %d\n",
47− on ? "on" : "off", error);
48+ str_on_off(on), error);
4849 return error;
4950 }
5051
drivers/input/mouse/elan_i2c_core.c+2−1
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/slab.h>
2929 #include <linux/kernel.h>
3030 #include <linux/sched.h>
31+#include <linux/string_choices.h>
3132 #include <linux/input.h>
3233 #include <linux/uaccess.h>
3334 #include <linux/jiffies.h>
@@ -199,7 +200,7 @@ static int elan_set_power(struct elan_tp_data *data, bool on) · 165 unmodified lines
199200 } while (--repeat > 0);
200201
201202 dev_err(&data->client->dev, "failed to set power %s: %d\n",
202− on ? "on" : "off", error);
203+ str_on_off(on), error);
203204 return error;
204205 }
205206
drivers/input/mouse/synaptics.c+42−14
@@ -665,23 +665,50 @@ static void synaptics_pt_stop(struct serio *serio) · 664 unmodified lines
665665 priv->pt_port = NULL;
666666 }
667667
668+static int synaptics_pt_open(struct serio *serio)
669+{
670+ struct psmouse *parent = psmouse_from_serio(serio->parent);
671+ struct synaptics_data *priv = parent->private;
672+
673+ guard(serio_pause_rx)(parent->ps2dev.serio);
674+ priv->pt_port_open = true;
675+
676+ return 0;
677+}
678+
679+static void synaptics_pt_close(struct serio *serio)
680+{
681+ struct psmouse *parent = psmouse_from_serio(serio->parent);
682+ struct synaptics_data *priv = parent->private;
683+
684+ guard(serio_pause_rx)(parent->ps2dev.serio);
685+ priv->pt_port_open = false;
686+}
687+
668688 static int synaptics_is_pt_packet(u8 *buf)
669689 {
670690 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4;
671691 }
672692
673−static void synaptics_pass_pt_packet(struct serio *ptport, u8 *packet)
693+static void synaptics_pass_pt_packet(struct synaptics_data *priv, u8 *packet)
674694 {
675− struct psmouse *child = psmouse_from_serio(ptport);
695+ struct serio *ptport;
676696
677− if (child && child->state == PSMOUSE_ACTIVATED) {
678− serio_interrupt(ptport, packet[1], 0);
679− serio_interrupt(ptport, packet[4], 0);
680− serio_interrupt(ptport, packet[5], 0);
681− if (child->pktsize == 4)
682− serio_interrupt(ptport, packet[2], 0);
683− } else {
684− serio_interrupt(ptport, packet[1], 0);
697+ ptport = priv->pt_port;
698+ if (!ptport)
699+ return;
700+
701+ serio_interrupt(ptport, packet[1], 0);
702+
703+ if (priv->pt_port_open) {
704+ struct psmouse *child = psmouse_from_serio(ptport);
705+
706+ if (child->state == PSMOUSE_ACTIVATED) {
707+ serio_interrupt(ptport, packet[4], 0);
708+ serio_interrupt(ptport, packet[5], 0);
709+ if (child->pktsize == 4)
710+ serio_interrupt(ptport, packet[2], 0);
711+ }
685712 }
686713 }
687714
@@ -720,6 +747,8 @@ static void synaptics_pt_create(struct psmouse *psmouse) · 32 unmodified lines
720747 serio->write = synaptics_pt_write;
721748 serio->start = synaptics_pt_start;
722749 serio->stop = synaptics_pt_stop;
750+ serio->open = synaptics_pt_open;
751+ serio->close = synaptics_pt_close;
723752 serio->parent = psmouse->ps2dev.serio;
724753
725754 psmouse->pt_activate = synaptics_pt_activate;
@@ -1216,11 +1245,10 @@ static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse) · 490 unmodified lines
12161245
12171246 if (SYN_CAP_PASS_THROUGH(priv->info.capabilities) &&
12181247 synaptics_is_pt_packet(psmouse->packet)) {
1219− if (priv->pt_port)
1220− synaptics_pass_pt_packet(priv->pt_port,
1221− psmouse->packet);
1222− } else
1248+ synaptics_pass_pt_packet(priv, psmouse->packet);
1249+ } else {
12231250 synaptics_process_packet(psmouse);
1251+ }
12241252
12251253 return PSMOUSE_FULL_PACKET;
12261254 }
drivers/input/mouse/synaptics.h+1−0
@@ -188,6 +188,7 @@ struct synaptics_data { · 187 unmodified lines
188188 bool disable_gesture; /* disable gestures */
189189
190190 struct serio *pt_port; /* Pass-through serio port */
191+ bool pt_port_open;
191192
192193 /*
193194 * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
drivers/input/touchscreen/egalax_ts.c+2−1
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include <linux/gpio/consumer.h>
2424 #include <linux/delay.h>
2525 #include <linux/slab.h>
26+#include <linux/string_choices.h>
2627 #include <linux/bitops.h>
2728 #include <linux/input/mt.h>
2829
@@ -102,7 +103,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) · 73 unmodified lines
102103 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
103104
104105 dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
105− down ? "down" : "up", id, x, y, z);
106+ str_down_up(down), id, x, y, z);
106107
107108 if (down) {
108109 input_report_abs(input_dev, ABS_MT_POSITION_X, x);
include/linux/platform_data/keyscan-davinci.h+0−29
@@ -1,29 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-or-later */
2−/*
3− * Copyright (C) 2009 Texas Instruments, Inc
4− *
5− * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com>
6− */
7−
8−#ifndef DAVINCI_KEYSCAN_H
9−#define DAVINCI_KEYSCAN_H
10−
11−#include <linux/io.h>
12−
13−enum davinci_matrix_types {
14− DAVINCI_KEYSCAN_MATRIX_4X4,
15− DAVINCI_KEYSCAN_MATRIX_5X3,
16−};
17−
18−struct davinci_ks_platform_data {
19− int (*device_enable)(struct device *dev);
20− unsigned short *keymap;
21− u32 keymapsize;
22− u8 rep:1;
23− u8 strobe;
24− u8 interval;
25− u8 matrix_type;
26−};
27−
28−#endif
29−