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