Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+275 -468
-14
drivers/input/Kconfig
··· 152 152 To compile this driver as a module, choose M here: the 153 153 module will be called evdev. 154 154 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 - 169 155 config INPUT_KUNIT_TEST 170 156 tristate "KUnit tests for Input" if !KUNIT_ALL_TESTS 171 157 depends on INPUT && KUNIT
-1
drivers/input/Makefile
··· 18 18 obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o 19 19 obj-$(CONFIG_INPUT_JOYDEV) += joydev.o 20 20 obj-$(CONFIG_INPUT_EVDEV) += evdev.o 21 - obj-$(CONFIG_INPUT_EVBUG) += evbug.o 22 21 23 22 obj-$(CONFIG_INPUT_KEYBOARD) += keyboard/ 24 23 obj-$(CONFIG_INPUT_MOUSE) += mouse/
-100
drivers/input/evbug.c
··· 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);
+36 -55
drivers/input/ff-core.c
··· 93 93 { 94 94 struct ff_device *ff = dev->ff; 95 95 struct ff_effect *old; 96 - int ret = 0; 96 + int error; 97 97 int id; 98 98 99 99 if (!test_bit(EV_FF, dev->evbit)) ··· 114 114 } 115 115 116 116 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; 120 120 } 121 121 122 - mutex_lock(&ff->mutex); 122 + guard(mutex)(&ff->mutex); 123 123 124 124 if (effect->id == -1) { 125 125 for (id = 0; id < ff->max_effects; id++) 126 126 if (!ff->effect_owners[id]) 127 127 break; 128 128 129 - if (id >= ff->max_effects) { 130 - ret = -ENOSPC; 131 - goto out; 132 - } 129 + if (id >= ff->max_effects) 130 + return -ENOSPC; 133 131 134 132 effect->id = id; 135 133 old = NULL; ··· 135 137 } else { 136 138 id = effect->id; 137 139 138 - ret = check_effect_access(ff, id, file); 139 - if (ret) 140 - goto out; 140 + error = check_effect_access(ff, id, file); 141 + if (error) 142 + return error; 141 143 142 144 old = &ff->effects[id]; 143 145 144 - if (!check_effects_compatible(effect, old)) { 145 - ret = -EINVAL; 146 - goto out; 147 - } 146 + if (!check_effects_compatible(effect, old)) 147 + return -EINVAL; 148 148 } 149 149 150 - ret = ff->upload(dev, effect, old); 151 - if (ret) 152 - goto out; 150 + error = ff->upload(dev, effect, old); 151 + if (error) 152 + return error; 153 153 154 - spin_lock_irq(&dev->event_lock); 155 - ff->effects[id] = *effect; 156 - ff->effect_owners[id] = file; 157 - spin_unlock_irq(&dev->event_lock); 154 + scoped_guard(spinlock_irq, &dev->event_lock) { 155 + ff->effects[id] = *effect; 156 + ff->effect_owners[id] = file; 157 + } 158 158 159 - out: 160 - mutex_unlock(&ff->mutex); 161 - return ret; 159 + return 0; 162 160 } 163 161 EXPORT_SYMBOL_GPL(input_ff_upload); 164 162 ··· 172 178 if (error) 173 179 return error; 174 180 175 - spin_lock_irq(&dev->event_lock); 176 - ff->playback(dev, effect_id, 0); 177 - ff->effect_owners[effect_id] = NULL; 178 - spin_unlock_irq(&dev->event_lock); 181 + scoped_guard(spinlock_irq, &dev->event_lock) { 182 + ff->playback(dev, effect_id, 0); 183 + ff->effect_owners[effect_id] = NULL; 184 + } 179 185 180 186 if (ff->erase) { 181 187 error = ff->erase(dev, effect_id); 182 188 if (error) { 183 - spin_lock_irq(&dev->event_lock); 184 - ff->effect_owners[effect_id] = file; 185 - spin_unlock_irq(&dev->event_lock); 189 + scoped_guard(spinlock_irq, &dev->event_lock) 190 + ff->effect_owners[effect_id] = file; 186 191 187 192 return error; 188 193 } ··· 203 210 int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file) 204 211 { 205 212 struct ff_device *ff = dev->ff; 206 - int ret; 207 213 208 214 if (!test_bit(EV_FF, dev->evbit)) 209 215 return -ENOSYS; 210 216 211 - mutex_lock(&ff->mutex); 212 - ret = erase_effect(dev, effect_id, file); 213 - mutex_unlock(&ff->mutex); 214 - 215 - return ret; 217 + guard(mutex)(&ff->mutex); 218 + return erase_effect(dev, effect_id, file); 216 219 } 217 220 EXPORT_SYMBOL_GPL(input_ff_erase); 218 221 ··· 228 239 229 240 dev_dbg(&dev->dev, "flushing now\n"); 230 241 231 - mutex_lock(&ff->mutex); 242 + guard(mutex)(&ff->mutex); 232 243 233 244 for (i = 0; i < ff->max_effects; i++) 234 245 erase_effect(dev, i, file); 235 - 236 - mutex_unlock(&ff->mutex); 237 246 238 247 return 0; 239 248 } ··· 290 303 */ 291 304 int input_ff_create(struct input_dev *dev, unsigned int max_effects) 292 305 { 293 - struct ff_device *ff; 294 - size_t ff_dev_size; 295 306 int i; 296 307 297 308 if (!max_effects) { ··· 302 317 return -EINVAL; 303 318 } 304 319 305 - ff_dev_size = struct_size(ff, effect_owners, max_effects); 306 - if (ff_dev_size == SIZE_MAX) /* overflow */ 307 - return -EINVAL; 308 - 309 - ff = kzalloc(ff_dev_size, GFP_KERNEL); 320 + struct ff_device *ff __free(kfree) = 321 + kzalloc(struct_size(ff, effect_owners, max_effects), 322 + GFP_KERNEL); 310 323 if (!ff) 311 324 return -ENOMEM; 312 325 313 - ff->effects = kcalloc(max_effects, sizeof(struct ff_effect), 314 - GFP_KERNEL); 315 - if (!ff->effects) { 316 - kfree(ff); 326 + ff->effects = kcalloc(max_effects, sizeof(*ff->effects), GFP_KERNEL); 327 + if (!ff->effects) 317 328 return -ENOMEM; 318 - } 319 329 320 330 ff->max_effects = max_effects; 321 331 mutex_init(&ff->mutex); 322 332 323 - dev->ff = ff; 324 333 dev->flush = input_ff_flush; 325 334 dev->event = input_ff_event; 326 335 __set_bit(EV_FF, dev->evbit); ··· 326 347 /* we can emulate RUMBLE with periodic effects */ 327 348 if (test_bit(FF_PERIODIC, ff->ffbit)) 328 349 __set_bit(FF_RUMBLE, dev->ffbit); 350 + 351 + dev->ff = no_free_ptr(ff); 329 352 330 353 return 0; 331 354 }
+6 -12
drivers/input/ff-memless.c
··· 401 401 { 402 402 struct ml_device *ml = from_timer(ml, t, timer); 403 403 struct input_dev *dev = ml->dev; 404 - unsigned long flags; 405 404 406 405 pr_debug("timer: updating effects\n"); 407 406 408 - spin_lock_irqsave(&dev->event_lock, flags); 407 + guard(spinlock_irqsave)(&dev->event_lock); 409 408 ml_play_effects(ml); 410 - spin_unlock_irqrestore(&dev->event_lock, flags); 411 409 } 412 410 413 411 /* ··· 463 465 struct ml_device *ml = dev->ff->private; 464 466 struct ml_effect_state *state = &ml->states[effect->id]; 465 467 466 - spin_lock_irq(&dev->event_lock); 468 + guard(spinlock_irq)(&dev->event_lock); 467 469 468 470 if (test_bit(FF_EFFECT_STARTED, &state->flags)) { 469 471 __clear_bit(FF_EFFECT_PLAYING, &state->flags); ··· 474 476 state->adj_at = state->play_at; 475 477 ml_schedule_timer(ml); 476 478 } 477 - 478 - spin_unlock_irq(&dev->event_lock); 479 479 480 480 return 0; 481 481 } ··· 503 507 int input_ff_create_memless(struct input_dev *dev, void *data, 504 508 int (*play_effect)(struct input_dev *, void *, struct ff_effect *)) 505 509 { 506 - struct ml_device *ml; 507 510 struct ff_device *ff; 508 511 int error; 509 512 int i; 510 513 511 - ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL); 514 + struct ml_device *ml __free(kfree) = kzalloc(sizeof(*ml), GFP_KERNEL); 512 515 if (!ml) 513 516 return -ENOMEM; 514 517 ··· 520 525 set_bit(FF_GAIN, dev->ffbit); 521 526 522 527 error = input_ff_create(dev, FF_MEMLESS_EFFECTS); 523 - if (error) { 524 - kfree(ml); 528 + if (error) 525 529 return error; 526 - } 527 530 528 531 ff = dev->ff; 529 - ff->private = ml; 530 532 ff->upload = ml_ff_upload; 531 533 ff->playback = ml_ff_playback; 532 534 ff->set_gain = ml_ff_set_gain; ··· 539 547 540 548 for (i = 0; i < FF_MEMLESS_EFFECTS; i++) 541 549 ml->states[i].effect = &ff->effects[i]; 550 + 551 + ff->private = no_free_ptr(ml); 542 552 543 553 return 0; 544 554 }
+12 -22
drivers/input/input-mt.c
··· 39 39 int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, 40 40 unsigned int flags) 41 41 { 42 - struct input_mt *mt = dev->mt; 43 - int i; 44 - 45 42 if (!num_slots) 46 43 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 + 49 48 /* Arbitrary limit for avoiding too large memory allocation. */ 50 49 if (num_slots > 1024) 51 50 return -EINVAL; 52 51 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); 54 54 if (!mt) 55 - goto err_mem; 55 + return -ENOMEM; 56 56 57 57 mt->num_slots = num_slots; 58 58 mt->flags = flags; ··· 86 86 unsigned int n2 = num_slots * num_slots; 87 87 mt->red = kcalloc(n2, sizeof(*mt->red), GFP_KERNEL); 88 88 if (!mt->red) 89 - goto err_mem; 89 + return -ENOMEM; 90 90 } 91 91 92 92 /* Mark slots as 'inactive' */ 93 - for (i = 0; i < num_slots; i++) 93 + for (unsigned int i = 0; i < num_slots; i++) 94 94 input_mt_set_value(&mt->slots[i], ABS_MT_TRACKING_ID, -1); 95 95 96 96 /* Mark slots as 'unused' */ 97 97 mt->frame = 1; 98 98 99 - dev->mt = mt; 99 + dev->mt = no_free_ptr(mt); 100 100 return 0; 101 - err_mem: 102 - kfree(mt); 103 - return -ENOMEM; 104 101 } 105 102 EXPORT_SYMBOL(input_mt_init_slots); 106 103 ··· 282 285 struct input_mt *mt = dev->mt; 283 286 284 287 if (mt) { 285 - unsigned long flags; 286 - 287 - spin_lock_irqsave(&dev->event_lock, flags); 288 + guard(spinlock_irqsave)(&dev->event_lock); 288 289 289 290 __input_mt_drop_unused(dev, mt); 290 291 mt->frame++; 291 - 292 - spin_unlock_irqrestore(&dev->event_lock, flags); 293 292 } 294 293 } 295 294 EXPORT_SYMBOL(input_mt_drop_unused); ··· 332 339 return; 333 340 334 341 if (mt->flags & INPUT_MT_DROP_UNUSED) { 335 - unsigned long flags; 336 - 337 - spin_lock_irqsave(&dev->event_lock, flags); 342 + guard(spinlock_irqsave)(&dev->event_lock); 338 343 __input_mt_drop_unused(dev, mt); 339 - spin_unlock_irqrestore(&dev->event_lock, flags); 340 344 } 341 345 342 346 if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT))
+1 -3
drivers/input/input-poller.c
··· 162 162 if (interval > poller->poll_interval_max) 163 163 return -EINVAL; 164 164 165 - mutex_lock(&input->mutex); 165 + guard(mutex)(&input->mutex); 166 166 167 167 poller->poll_interval = interval; 168 168 ··· 171 171 if (poller->poll_interval > 0) 172 172 input_dev_poller_queue_work(poller); 173 173 } 174 - 175 - mutex_unlock(&input->mutex); 176 174 177 175 return count; 178 176 }
+131 -208
drivers/input/input.c
··· 115 115 116 116 lockdep_assert_held(&dev->event_lock); 117 117 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 + } 119 124 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) { 125 126 if (handle->open) { 126 127 count = handle->handle_events(handle, vals, 127 128 count); 128 129 if (!count) 129 130 break; 130 131 } 132 + } 131 133 } 132 - 133 - rcu_read_unlock(); 134 134 135 135 /* trigger auto repeat for key events */ 136 136 if (test_bit(EV_REP, dev->evbit) && test_bit(EV_KEY, dev->evbit)) { ··· 390 390 void input_event(struct input_dev *dev, 391 391 unsigned int type, unsigned int code, int value) 392 392 { 393 - unsigned long flags; 394 - 395 393 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); 398 395 input_handle_event(dev, type, code, value); 399 - spin_unlock_irqrestore(&dev->event_lock, flags); 400 396 } 401 397 } 402 398 EXPORT_SYMBOL(input_event); ··· 413 417 { 414 418 struct input_dev *dev = handle->dev; 415 419 struct input_handle *grab; 416 - unsigned long flags; 417 420 418 421 if (is_event_supported(type, dev->evbit, EV_MAX)) { 419 - spin_lock_irqsave(&dev->event_lock, flags); 422 + guard(spinlock_irqsave)(&dev->event_lock); 423 + guard(rcu)(); 420 424 421 - rcu_read_lock(); 422 425 grab = rcu_dereference(dev->grab); 423 426 if (!grab || grab == handle) 424 427 input_handle_event(dev, type, code, value); 425 - rcu_read_unlock(); 426 428 427 - spin_unlock_irqrestore(&dev->event_lock, flags); 428 429 } 429 430 } 430 431 EXPORT_SYMBOL(input_inject_event); ··· 519 526 int input_grab_device(struct input_handle *handle) 520 527 { 521 528 struct input_dev *dev = handle->dev; 522 - int retval; 523 529 524 - retval = mutex_lock_interruptible(&dev->mutex); 525 - if (retval) 526 - return retval; 530 + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { 531 + if (dev->grab) 532 + return -EBUSY; 527 533 528 - if (dev->grab) { 529 - retval = -EBUSY; 530 - goto out; 534 + rcu_assign_pointer(dev->grab, handle); 531 535 } 532 536 533 - rcu_assign_pointer(dev->grab, handle); 534 - 535 - out: 536 - mutex_unlock(&dev->mutex); 537 - return retval; 537 + return 0; 538 538 } 539 539 EXPORT_SYMBOL(input_grab_device); 540 540 ··· 562 576 { 563 577 struct input_dev *dev = handle->dev; 564 578 565 - mutex_lock(&dev->mutex); 579 + guard(mutex)(&dev->mutex); 566 580 __input_release_device(handle); 567 - mutex_unlock(&dev->mutex); 568 581 } 569 582 EXPORT_SYMBOL(input_release_device); 570 583 ··· 577 592 int input_open_device(struct input_handle *handle) 578 593 { 579 594 struct input_dev *dev = handle->dev; 580 - int retval; 595 + int error; 581 596 582 - retval = mutex_lock_interruptible(&dev->mutex); 583 - if (retval) 584 - return retval; 597 + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { 598 + if (dev->going_away) 599 + return -ENODEV; 585 600 586 - if (dev->going_away) { 587 - retval = -ENODEV; 588 - goto out; 589 - } 601 + handle->open++; 590 602 591 - handle->open++; 603 + if (handle->handler->passive_observer) 604 + return 0; 592 605 593 - if (handle->handler->passive_observer) 594 - goto out; 595 - 596 - if (dev->users++ || dev->inhibited) { 597 - /* 598 - * Device is already opened and/or inhibited, 599 - * so we can exit immediately and report success. 600 - */ 601 - goto out; 602 - } 603 - 604 - if (dev->open) { 605 - retval = dev->open(dev); 606 - if (retval) { 607 - dev->users--; 608 - handle->open--; 606 + if (dev->users++ || dev->inhibited) { 609 607 /* 610 - * Make sure we are not delivering any more events 611 - * through this handle 608 + * Device is already opened and/or inhibited, 609 + * so we can exit immediately and report success. 612 610 */ 613 - synchronize_rcu(); 614 - goto out; 611 + return 0; 615 612 } 613 + 614 + if (dev->open) { 615 + error = dev->open(dev); 616 + if (error) { 617 + dev->users--; 618 + handle->open--; 619 + /* 620 + * Make sure we are not delivering any more 621 + * events through this handle. 622 + */ 623 + synchronize_rcu(); 624 + return error; 625 + } 626 + } 627 + 628 + if (dev->poller) 629 + input_dev_poller_start(dev->poller); 616 630 } 617 631 618 - if (dev->poller) 619 - input_dev_poller_start(dev->poller); 620 - 621 - out: 622 - mutex_unlock(&dev->mutex); 623 - return retval; 632 + return 0; 624 633 } 625 634 EXPORT_SYMBOL(input_open_device); 626 635 627 636 int input_flush_device(struct input_handle *handle, struct file *file) 628 637 { 629 638 struct input_dev *dev = handle->dev; 630 - int retval; 631 639 632 - retval = mutex_lock_interruptible(&dev->mutex); 633 - if (retval) 634 - return retval; 640 + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { 641 + if (dev->flush) 642 + return dev->flush(dev, file); 643 + } 635 644 636 - if (dev->flush) 637 - retval = dev->flush(dev, file); 638 - 639 - mutex_unlock(&dev->mutex); 640 - return retval; 645 + return 0; 641 646 } 642 647 EXPORT_SYMBOL(input_flush_device); 643 648 ··· 642 667 { 643 668 struct input_dev *dev = handle->dev; 644 669 645 - mutex_lock(&dev->mutex); 670 + guard(mutex)(&dev->mutex); 646 671 647 672 __input_release_device(handle); 648 673 ··· 663 688 */ 664 689 synchronize_rcu(); 665 690 } 666 - 667 - mutex_unlock(&dev->mutex); 668 691 } 669 692 EXPORT_SYMBOL(input_close_device); 670 693 ··· 699 726 * not to protect access to dev->going_away but rather to ensure 700 727 * that there are no threads in the middle of input_open_device() 701 728 */ 702 - mutex_lock(&dev->mutex); 703 - dev->going_away = true; 704 - mutex_unlock(&dev->mutex); 729 + scoped_guard(mutex, &dev->mutex) 730 + dev->going_away = true; 705 731 706 - spin_lock_irq(&dev->event_lock); 732 + guard(spinlock_irq)(&dev->event_lock); 707 733 708 734 /* 709 735 * Simulate keyup events for all pressed keys so that handlers ··· 715 743 716 744 list_for_each_entry(handle, &dev->h_list, d_node) 717 745 handle->open = 0; 718 - 719 - spin_unlock_irq(&dev->event_lock); 720 746 } 721 747 722 748 /** ··· 871 901 */ 872 902 int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke) 873 903 { 874 - unsigned long flags; 875 - int retval; 904 + guard(spinlock_irqsave)(&dev->event_lock); 876 905 877 - spin_lock_irqsave(&dev->event_lock, flags); 878 - retval = dev->getkeycode(dev, ke); 879 - spin_unlock_irqrestore(&dev->event_lock, flags); 880 - 881 - return retval; 906 + return dev->getkeycode(dev, ke); 882 907 } 883 908 EXPORT_SYMBOL(input_get_keycode); 884 909 ··· 888 923 int input_set_keycode(struct input_dev *dev, 889 924 const struct input_keymap_entry *ke) 890 925 { 891 - unsigned long flags; 892 926 unsigned int old_keycode; 893 - int retval; 927 + int error; 894 928 895 929 if (ke->keycode > KEY_MAX) 896 930 return -EINVAL; 897 931 898 - spin_lock_irqsave(&dev->event_lock, flags); 932 + guard(spinlock_irqsave)(&dev->event_lock); 899 933 900 - retval = dev->setkeycode(dev, ke, &old_keycode); 901 - if (retval) 902 - goto out; 934 + error = dev->setkeycode(dev, ke, &old_keycode); 935 + if (error) 936 + return error; 903 937 904 938 /* Make sure KEY_RESERVED did not get enabled. */ 905 939 __clear_bit(KEY_RESERVED, dev->keybit); ··· 926 962 EV_SYN, SYN_REPORT, 1); 927 963 } 928 964 929 - out: 930 - spin_unlock_irqrestore(&dev->event_lock, flags); 931 - 932 - return retval; 965 + return 0; 933 966 } 934 967 EXPORT_SYMBOL(input_set_keycode); 935 968 ··· 1760 1799 */ 1761 1800 void input_reset_device(struct input_dev *dev) 1762 1801 { 1763 - unsigned long flags; 1764 - 1765 - mutex_lock(&dev->mutex); 1766 - spin_lock_irqsave(&dev->event_lock, flags); 1802 + guard(mutex)(&dev->mutex); 1803 + guard(spinlock_irqsave)(&dev->event_lock); 1767 1804 1768 1805 input_dev_toggle(dev, true); 1769 1806 if (input_dev_release_keys(dev)) 1770 1807 input_handle_event(dev, EV_SYN, SYN_REPORT, 1); 1771 - 1772 - spin_unlock_irqrestore(&dev->event_lock, flags); 1773 - mutex_unlock(&dev->mutex); 1774 1808 } 1775 1809 EXPORT_SYMBOL(input_reset_device); 1776 1810 1777 1811 static int input_inhibit_device(struct input_dev *dev) 1778 1812 { 1779 - mutex_lock(&dev->mutex); 1813 + guard(mutex)(&dev->mutex); 1780 1814 1781 1815 if (dev->inhibited) 1782 - goto out; 1816 + return 0; 1783 1817 1784 1818 if (dev->users) { 1785 1819 if (dev->close) ··· 1783 1827 input_dev_poller_stop(dev->poller); 1784 1828 } 1785 1829 1786 - spin_lock_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 - spin_unlock_irq(&dev->event_lock); 1830 + scoped_guard(spinlock_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 + } 1792 1836 1793 1837 dev->inhibited = true; 1794 1838 1795 - out: 1796 - mutex_unlock(&dev->mutex); 1797 1839 return 0; 1798 1840 } 1799 1841 1800 1842 static int input_uninhibit_device(struct input_dev *dev) 1801 1843 { 1802 - int ret = 0; 1844 + int error; 1803 1845 1804 - mutex_lock(&dev->mutex); 1846 + guard(mutex)(&dev->mutex); 1805 1847 1806 1848 if (!dev->inhibited) 1807 - goto out; 1849 + return 0; 1808 1850 1809 1851 if (dev->users) { 1810 1852 if (dev->open) { 1811 - ret = dev->open(dev); 1812 - if (ret) 1813 - goto out; 1853 + error = dev->open(dev); 1854 + if (error) 1855 + return error; 1814 1856 } 1815 1857 if (dev->poller) 1816 1858 input_dev_poller_start(dev->poller); 1817 1859 } 1818 1860 1819 1861 dev->inhibited = false; 1820 - spin_lock_irq(&dev->event_lock); 1821 - input_dev_toggle(dev, true); 1822 - spin_unlock_irq(&dev->event_lock); 1823 1862 1824 - out: 1825 - mutex_unlock(&dev->mutex); 1826 - return ret; 1863 + scoped_guard(spinlock_irq, &dev->event_lock) 1864 + input_dev_toggle(dev, true); 1865 + 1866 + return 0; 1827 1867 } 1828 1868 1829 1869 static int input_dev_suspend(struct device *dev) 1830 1870 { 1831 1871 struct input_dev *input_dev = to_input_dev(dev); 1832 1872 1833 - spin_lock_irq(&input_dev->event_lock); 1873 + guard(spinlock_irq)(&input_dev->event_lock); 1834 1874 1835 1875 /* 1836 1876 * Keys that are pressed now are unlikely to be ··· 1837 1885 1838 1886 /* Turn off LEDs and sounds, if any are active. */ 1839 1887 input_dev_toggle(input_dev, false); 1840 - 1841 - spin_unlock_irq(&input_dev->event_lock); 1842 1888 1843 1889 return 0; 1844 1890 } ··· 1845 1895 { 1846 1896 struct input_dev *input_dev = to_input_dev(dev); 1847 1897 1848 - spin_lock_irq(&input_dev->event_lock); 1898 + guard(spinlock_irq)(&input_dev->event_lock); 1849 1899 1850 1900 /* Restore state of LEDs and sounds, if any were active. */ 1851 1901 input_dev_toggle(input_dev, true); 1852 - 1853 - spin_unlock_irq(&input_dev->event_lock); 1854 1902 1855 1903 return 0; 1856 1904 } ··· 1857 1909 { 1858 1910 struct input_dev *input_dev = to_input_dev(dev); 1859 1911 1860 - spin_lock_irq(&input_dev->event_lock); 1912 + guard(spinlock_irq)(&input_dev->event_lock); 1861 1913 1862 1914 /* 1863 1915 * Keys that are pressed now are unlikely to be ··· 1866 1918 if (input_dev_release_keys(input_dev)) 1867 1919 input_handle_event(input_dev, EV_SYN, SYN_REPORT, 1); 1868 1920 1869 - spin_unlock_irq(&input_dev->event_lock); 1870 - 1871 1921 return 0; 1872 1922 } 1873 1923 ··· 1873 1927 { 1874 1928 struct input_dev *input_dev = to_input_dev(dev); 1875 1929 1876 - spin_lock_irq(&input_dev->event_lock); 1930 + guard(spinlock_irq)(&input_dev->event_lock); 1877 1931 1878 1932 /* Turn off LEDs and sounds, if any are active. */ 1879 1933 input_dev_toggle(input_dev, false); 1880 - 1881 - spin_unlock_irq(&input_dev->event_lock); 1882 1934 1883 1935 return 0; 1884 1936 } ··· 2218 2274 2219 2275 input_disconnect_device(dev); 2220 2276 2221 - mutex_lock(&input_mutex); 2277 + scoped_guard(mutex, &input_mutex) { 2278 + list_for_each_entry_safe(handle, next, &dev->h_list, d_node) 2279 + handle->handler->disconnect(handle); 2280 + WARN_ON(!list_empty(&dev->h_list)); 2222 2281 2223 - list_for_each_entry_safe(handle, next, &dev->h_list, d_node) 2224 - handle->handler->disconnect(handle); 2225 - WARN_ON(!list_empty(&dev->h_list)); 2282 + del_timer_sync(&dev->timer); 2283 + list_del_init(&dev->node); 2226 2284 2227 - del_timer_sync(&dev->timer); 2228 - list_del_init(&dev->node); 2229 - 2230 - input_wakeup_procfs_readers(); 2231 - 2232 - mutex_unlock(&input_mutex); 2285 + input_wakeup_procfs_readers(); 2286 + } 2233 2287 2234 2288 device_del(&dev->dev); 2235 2289 } ··· 2250 2308 static void input_repeat_key(struct timer_list *t) 2251 2309 { 2252 2310 struct input_dev *dev = from_timer(dev, t, timer); 2253 - unsigned long flags; 2254 2311 2255 - spin_lock_irqsave(&dev->event_lock, flags); 2312 + guard(spinlock_irqsave)(&dev->event_lock); 2256 2313 2257 2314 if (!dev->inhibited && 2258 2315 test_bit(dev->repeat_key, dev->key) && ··· 2265 2324 mod_timer(&dev->timer, jiffies + 2266 2325 msecs_to_jiffies(dev->rep[REP_PERIOD])); 2267 2326 } 2268 - 2269 - spin_unlock_irqrestore(&dev->event_lock, flags); 2270 2327 } 2271 2328 2272 2329 /** ··· 2309 2370 if (!vals) 2310 2371 return -ENOMEM; 2311 2372 2312 - spin_lock_irq(&dev->event_lock); 2313 - dev->max_vals = max_vals; 2314 - swap(dev->vals, vals); 2315 - spin_unlock_irq(&dev->event_lock); 2373 + scoped_guard(spinlock_irq, &dev->event_lock) { 2374 + dev->max_vals = max_vals; 2375 + swap(dev->vals, vals); 2376 + } 2316 2377 2317 2378 /* Because of swap() above, this frees the old vals memory */ 2318 2379 kfree(vals); ··· 2404 2465 path ? path : "N/A"); 2405 2466 kfree(path); 2406 2467 2407 - error = mutex_lock_interruptible(&input_mutex); 2408 - if (error) 2409 - goto err_device_del; 2468 + error = -EINTR; 2469 + scoped_cond_guard(mutex_intr, goto err_device_del, &input_mutex) { 2470 + list_add_tail(&dev->node, &input_dev_list); 2410 2471 2411 - list_add_tail(&dev->node, &input_dev_list); 2472 + list_for_each_entry(handler, &input_handler_list, node) 2473 + input_attach_handler(dev, handler); 2412 2474 2413 - list_for_each_entry(handler, &input_handler_list, node) 2414 - input_attach_handler(dev, handler); 2415 - 2416 - input_wakeup_procfs_readers(); 2417 - 2418 - mutex_unlock(&input_mutex); 2475 + input_wakeup_procfs_readers(); 2476 + } 2419 2477 2420 2478 if (dev->devres_managed) { 2421 2479 dev_dbg(dev->dev.parent, "%s: registering %s with devres.\n", ··· 2492 2556 if (error) 2493 2557 return error; 2494 2558 2495 - INIT_LIST_HEAD(&handler->h_list); 2559 + scoped_cond_guard(mutex_intr, return -EINTR, &input_mutex) { 2560 + INIT_LIST_HEAD(&handler->h_list); 2496 2561 2497 - error = mutex_lock_interruptible(&input_mutex); 2498 - if (error) 2499 - return error; 2562 + list_add_tail(&handler->node, &input_handler_list); 2500 2563 2501 - list_add_tail(&handler->node, &input_handler_list); 2564 + list_for_each_entry(dev, &input_dev_list, node) 2565 + input_attach_handler(dev, handler); 2502 2566 2503 - list_for_each_entry(dev, &input_dev_list, node) 2504 - input_attach_handler(dev, handler); 2567 + input_wakeup_procfs_readers(); 2568 + } 2505 2569 2506 - input_wakeup_procfs_readers(); 2507 - 2508 - mutex_unlock(&input_mutex); 2509 2570 return 0; 2510 2571 } 2511 2572 EXPORT_SYMBOL(input_register_handler); ··· 2518 2585 { 2519 2586 struct input_handle *handle, *next; 2520 2587 2521 - mutex_lock(&input_mutex); 2588 + guard(mutex)(&input_mutex); 2522 2589 2523 2590 list_for_each_entry_safe(handle, next, &handler->h_list, h_node) 2524 2591 handler->disconnect(handle); ··· 2527 2594 list_del_init(&handler->node); 2528 2595 2529 2596 input_wakeup_procfs_readers(); 2530 - 2531 - mutex_unlock(&input_mutex); 2532 2597 } 2533 2598 EXPORT_SYMBOL(input_unregister_handler); 2534 2599 ··· 2546 2615 int (*fn)(struct input_handle *, void *)) 2547 2616 { 2548 2617 struct input_handle *handle; 2549 - int retval = 0; 2618 + int retval; 2550 2619 2551 - rcu_read_lock(); 2620 + guard(rcu)(); 2552 2621 2553 2622 list_for_each_entry_rcu(handle, &handler->h_list, h_node) { 2554 2623 retval = fn(handle, data); 2555 2624 if (retval) 2556 - break; 2625 + return retval; 2557 2626 } 2558 2627 2559 - rcu_read_unlock(); 2560 - 2561 - return retval; 2628 + return 0; 2562 2629 } 2563 2630 EXPORT_SYMBOL(input_handler_for_each_handle); 2564 2631 ··· 2644 2715 { 2645 2716 struct input_handler *handler = handle->handler; 2646 2717 struct input_dev *dev = handle->dev; 2647 - int error; 2648 2718 2649 2719 input_handle_setup_event_handler(handle); 2650 2720 /* 2651 2721 * We take dev->mutex here to prevent race with 2652 2722 * input_release_device(). 2653 2723 */ 2654 - error = mutex_lock_interruptible(&dev->mutex); 2655 - if (error) 2656 - return error; 2657 - 2658 - /* 2659 - * Filters go to the head of the list, normal handlers 2660 - * to the tail. 2661 - */ 2662 - if (handler->filter) 2663 - list_add_rcu(&handle->d_node, &dev->h_list); 2664 - else 2665 - list_add_tail_rcu(&handle->d_node, &dev->h_list); 2666 - 2667 - mutex_unlock(&dev->mutex); 2724 + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { 2725 + /* 2726 + * Filters go to the head of the list, normal handlers 2727 + * to the tail. 2728 + */ 2729 + if (handler->filter) 2730 + list_add_rcu(&handle->d_node, &dev->h_list); 2731 + else 2732 + list_add_tail_rcu(&handle->d_node, &dev->h_list); 2733 + } 2668 2734 2669 2735 /* 2670 2736 * Since we are supposed to be called from ->connect() ··· 2695 2771 /* 2696 2772 * Take dev->mutex to prevent race with input_release_device(). 2697 2773 */ 2698 - mutex_lock(&dev->mutex); 2699 - list_del_rcu(&handle->d_node); 2700 - mutex_unlock(&dev->mutex); 2774 + scoped_guard(mutex, &dev->mutex) 2775 + list_del_rcu(&handle->d_node); 2701 2776 2702 2777 synchronize_rcu(); 2703 2778 }
+2 -1
drivers/input/joystick/sidewinder.c
··· 14 14 #include <linux/input.h> 15 15 #include <linux/gameport.h> 16 16 #include <linux/jiffies.h> 17 + #include <linux/string_choices.h> 17 18 18 19 #define DRIVER_DESC "Microsoft SideWinder joystick family driver" 19 20 ··· 678 677 case 48: /* Ambiguous */ 679 678 if (j == 14) { /* ID length 14*3 -> FFP */ 680 679 sw->type = SW_ID_FFP; 681 - sprintf(comment, " [AC %s]", sw_get_bits(idbuf,38,1,3) ? "off" : "on"); 680 + sprintf(comment, " [AC %s]", str_off_on(sw_get_bits(idbuf,38,1,3))); 682 681 } else 683 682 sw->type = SW_ID_PP; 684 683 break;
+8 -1
drivers/input/joystick/xpad.c
··· 150 150 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, 151 151 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 }, 152 152 { 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 }, 153 154 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE }, 154 155 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE }, 155 156 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE }, ··· 306 305 { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 }, 307 306 { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 }, 308 307 { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 }, 308 + { 0x1a86, 0xe310, "QH Electronics Controller", 0, XTYPE_XBOX360 }, 309 309 { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, 310 310 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 311 311 { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, ··· 375 373 { 0x294b, 0x3303, "Snakebyte GAMEPAD BASE X", 0, XTYPE_XBOXONE }, 376 374 { 0x294b, 0x3404, "Snakebyte GAMEPAD RGB X", 0, XTYPE_XBOXONE }, 377 375 { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, 378 - { 0x2dc8, 0x3106, "8BitDo Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, 376 + { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, 379 377 { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, 380 378 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, 381 379 { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, 382 380 { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, 383 381 { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, 384 382 { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 }, 383 + { 0x31e3, 0x1230, "Wooting Two HE (ARM)", 0, XTYPE_XBOX360 }, 385 384 { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, 386 385 { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, 387 386 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, 387 + { 0x3285, 0x0646, "Nacon Pro Compact", 0, XTYPE_XBOXONE }, 388 + { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE }, 388 389 { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, 389 390 { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, 390 391 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, ··· 519 514 XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ 520 515 XPAD_XBOX360_VENDOR(0x17ef), /* Lenovo */ 521 516 XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */ 517 + XPAD_XBOX360_VENDOR(0x1a86), /* QH Electronics */ 522 518 XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */ 523 519 XPAD_XBOX360_VENDOR(0x20d6), /* PowerA controllers */ 524 520 XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA controllers */ ··· 536 530 XPAD_XBOX360_VENDOR(0x2f24), /* GameSir controllers */ 537 531 XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ 538 532 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ 533 + XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */ 539 534 XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ 540 535 XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */ 541 536 { }
+1 -1
drivers/input/keyboard/atkbd.c
··· 89 89 0, 46, 45, 32, 18, 5, 4, 95, 0, 57, 47, 33, 20, 19, 6,183, 90 90 0, 49, 48, 35, 34, 21, 7,184, 0, 0, 50, 36, 22, 8, 9,185, 91 91 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, 93 93 0, 86, 91, 90, 92, 0, 14, 94, 0, 79,124, 75, 71,121, 0, 0, 94 94 82, 83, 80, 76, 77, 72, 1, 69, 87, 78, 81, 74, 55, 73, 70, 99, 95 95
+2 -1
drivers/input/keyboard/lm8323.c
··· 21 21 #include <linux/platform_data/lm8323.h> 22 22 #include <linux/pm.h> 23 23 #include <linux/slab.h> 24 + #include <linux/string_choices.h> 24 25 25 26 /* Commands to send to the chip. */ 26 27 #define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */ ··· 270 269 unsigned short keycode = lm->keymap[key]; 271 270 272 271 dev_vdbg(&lm->client->dev, "key 0x%02x %s\n", 273 - key, isdown ? "down" : "up"); 272 + key, str_down_up(isdown)); 274 273 275 274 if (lm->kp_enabled) { 276 275 input_event(lm->idev, EV_MSC, MSC_SCAN, key);
+2 -1
drivers/input/misc/max77693-haptic.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/pwm.h> 20 20 #include <linux/slab.h> 21 + #include <linux/string_choices.h> 21 22 #include <linux/workqueue.h> 22 23 #include <linux/regulator/consumer.h> 23 24 #include <linux/mfd/max77693.h> ··· 95 94 on << MAINCTRL1_BIASEN_SHIFT); 96 95 if (error) { 97 96 dev_err(haptic->dev, "failed to %s bias: %d\n", 98 - on ? "enable" : "disable", error); 97 + str_enable_disable(on), error); 99 98 return error; 100 99 } 101 100
+15 -1
drivers/input/misc/mma8450.c
··· 38 38 39 39 #define MMA8450_CTRL_REG1 0x38 40 40 #define MMA8450_CTRL_REG2 0x39 41 + #define MMA8450_ID 0xc6 42 + #define MMA8450_WHO_AM_I 0x0f 41 43 42 44 static int mma8450_read(struct i2c_client *c, unsigned int off) 43 45 { ··· 150 148 */ 151 149 static int mma8450_probe(struct i2c_client *c) 152 150 { 151 + struct i2c_adapter *adapter = c->adapter; 153 152 struct input_dev *input; 154 - int err; 153 + int err, client_id; 154 + 155 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE | 156 + I2C_FUNC_SMBUS_BYTE_DATA)) 157 + return dev_err_probe(&c->dev, -EINVAL, 158 + "I2C adapter doesn't support SMBUS BYTE"); 159 + 160 + client_id = i2c_smbus_read_byte_data(c, MMA8450_WHO_AM_I); 161 + if (client_id != MMA8450_ID) 162 + return dev_err_probe(&c->dev, -EINVAL, 163 + "unexpected chip ID 0x%x (vs 0x%x)\n", 164 + client_id, MMA8450_ID); 155 165 156 166 input = devm_input_allocate_device(&c->dev); 157 167 if (!input)
+8
drivers/input/misc/nxp-bbnsm-pwrkey.c
··· 187 187 return 0; 188 188 } 189 189 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 + 190 196 static int __maybe_unused bbnsm_pwrkey_suspend(struct device *dev) 191 197 { 192 198 struct platform_device *pdev = to_platform_device(dev); ··· 229 223 .of_match_table = bbnsm_pwrkey_ids, 230 224 }, 231 225 .probe = bbnsm_pwrkey_probe, 226 + .remove = bbnsm_pwrkey_remove, 227 + 232 228 }; 233 229 module_platform_driver(bbnsm_pwrkey_driver); 234 230
+2 -1
drivers/input/misc/regulator-haptic.c
··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/regulator/consumer.h> 16 16 #include <linux/slab.h> 17 + #include <linux/string_choices.h> 17 18 18 19 #define MAX_MAGNITUDE_SHIFT 16 19 20 ··· 45 44 if (error) { 46 45 dev_err(haptic->dev, 47 46 "failed to switch regulator %s: %d\n", 48 - on ? "on" : "off", error); 47 + str_on_off(on), error); 49 48 return error; 50 49 } 51 50
+2 -1
drivers/input/mouse/elan_i2c_core.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/kernel.h> 30 30 #include <linux/sched.h> 31 + #include <linux/string_choices.h> 31 32 #include <linux/input.h> 32 33 #include <linux/uaccess.h> 33 34 #include <linux/jiffies.h> ··· 200 199 } while (--repeat > 0); 201 200 202 201 dev_err(&data->client->dev, "failed to set power %s: %d\n", 203 - on ? "on" : "off", error); 202 + str_on_off(on), error); 204 203 return error; 205 204 } 206 205
+42 -14
drivers/input/mouse/synaptics.c
··· 665 665 priv->pt_port = NULL; 666 666 } 667 667 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 + 668 688 static int synaptics_is_pt_packet(u8 *buf) 669 689 { 670 690 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; 671 691 } 672 692 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) 674 694 { 675 - struct psmouse *child = psmouse_from_serio(ptport); 695 + struct serio *ptport; 676 696 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 + } 685 712 } 686 713 } 687 714 ··· 747 720 serio->write = synaptics_pt_write; 748 721 serio->start = synaptics_pt_start; 749 722 serio->stop = synaptics_pt_stop; 723 + serio->open = synaptics_pt_open; 724 + serio->close = synaptics_pt_close; 750 725 serio->parent = psmouse->ps2dev.serio; 751 726 752 727 psmouse->pt_activate = synaptics_pt_activate; ··· 1245 1216 1246 1217 if (SYN_CAP_PASS_THROUGH(priv->info.capabilities) && 1247 1218 synaptics_is_pt_packet(psmouse->packet)) { 1248 - if (priv->pt_port) 1249 - synaptics_pass_pt_packet(priv->pt_port, 1250 - psmouse->packet); 1251 - } else 1219 + synaptics_pass_pt_packet(priv, psmouse->packet); 1220 + } else { 1252 1221 synaptics_process_packet(psmouse); 1222 + } 1253 1223 1254 1224 return PSMOUSE_FULL_PACKET; 1255 1225 }
+1
drivers/input/mouse/synaptics.h
··· 188 188 bool disable_gesture; /* disable gestures */ 189 189 190 190 struct serio *pt_port; /* Pass-through serio port */ 191 + bool pt_port_open; 191 192 192 193 /* 193 194 * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
+2 -1
drivers/input/touchscreen/egalax_ts.c
··· 23 23 #include <linux/gpio/consumer.h> 24 24 #include <linux/delay.h> 25 25 #include <linux/slab.h> 26 + #include <linux/string_choices.h> 26 27 #include <linux/bitops.h> 27 28 #include <linux/input/mt.h> 28 29 ··· 103 102 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down); 104 103 105 104 dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d", 106 - down ? "down" : "up", id, x, y, z); 105 + str_down_up(down), id, x, y, z); 107 106 108 107 if (down) { 109 108 input_report_abs(input_dev, ABS_MT_POSITION_X, x);
-29
include/linux/platform_data/keyscan-davinci.h
··· 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 -