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 | 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 |
| @@ -18,7 +18,6 @@ obj-$(CONFIG_INPUT_LEDS) += input-leds.o · 17 unmodified lines | ||
| 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/ |
| @@ -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 | 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,22 +114,20 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, · 14 unmodified lines | ||
| 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; |
| @@ -137,30 +135,26 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, · 1 unmodified line | ||
| 137 | 135 | } else { |
| 138 | 136 | id = effect->id; |
| 139 | 137 | |
| 140 | − ret = check_effect_access(ff, id, file); | |
| 141 | − if (ret) | |
| 142 | − goto out; | |
| 138 | + error = check_effect_access(ff, id, file); | |
| 139 | + if (error) | |
| 140 | + return error; | |
| 143 | 141 | |
| 144 | 142 | old = &ff->effects[id]; |
| 145 | 143 | |
| 146 | − if (!check_effects_compatible(effect, old)) { | |
| 147 | − ret = -EINVAL; | |
| 148 | − goto out; | |
| 149 | − } | |
| 144 | + if (!check_effects_compatible(effect, old)) | |
| 145 | + return -EINVAL; | |
| 150 | 146 | } |
| 151 | 147 | |
| 152 | − ret = ff->upload(dev, effect, old); | |
| 153 | − if (ret) | |
| 154 | − goto out; | |
| 148 | + error = ff->upload(dev, effect, old); | |
| 149 | + if (error) | |
| 150 | + return error; | |
| 155 | 151 | |
| 156 | − spin_lock_irq(&dev->event_lock); | |
| 157 | − ff->effects[id] = *effect; | |
| 158 | − ff->effect_owners[id] = file; | |
| 159 | − spin_unlock_irq(&dev->event_lock); | |
| 152 | + scoped_guard(spinlock_irq, &dev->event_lock) { | |
| 153 | + ff->effects[id] = *effect; | |
| 154 | + ff->effect_owners[id] = file; | |
| 155 | + } | |
| 160 | 156 | |
| 161 | − out: | |
| 162 | − mutex_unlock(&ff->mutex); | |
| 163 | − return ret; | |
| 157 | + return 0; | |
| 164 | 158 | } |
| 165 | 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 | 172 | if (error) |
| 179 | 173 | return error; |
| 180 | 174 | |
| 181 | − spin_lock_irq(&dev->event_lock); | |
| 182 | − ff->playback(dev, effect_id, 0); | |
| 183 | − ff->effect_owners[effect_id] = NULL; | |
| 184 | − spin_unlock_irq(&dev->event_lock); | |
| 175 | + scoped_guard(spinlock_irq, &dev->event_lock) { | |
| 176 | + ff->playback(dev, effect_id, 0); | |
| 177 | + ff->effect_owners[effect_id] = NULL; | |
| 178 | + } | |
| 185 | 179 | |
| 186 | 180 | if (ff->erase) { |
| 187 | 181 | error = ff->erase(dev, effect_id); |
| 188 | 182 | if (error) { |
| 189 | − spin_lock_irq(&dev->event_lock); | |
| 190 | − ff->effect_owners[effect_id] = file; | |
| 191 | − spin_unlock_irq(&dev->event_lock); | |
| 183 | + scoped_guard(spinlock_irq, &dev->event_lock) | |
| 184 | + ff->effect_owners[effect_id] = file; | |
| 192 | 185 | |
| 193 | 186 | return error; |
| 194 | 187 | } |
| @@ -210,16 +203,12 @@ static int erase_effect(struct input_dev *dev, int effect_id, · 15 unmodified lines | ||
| 210 | 203 | int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file) |
| 211 | 204 | { |
| 212 | 205 | struct ff_device *ff = dev->ff; |
| 213 | − int ret; | |
| 214 | 206 | |
| 215 | 207 | if (!test_bit(EV_FF, dev->evbit)) |
| 216 | 208 | return -ENOSYS; |
| 217 | 209 | |
| 218 | − mutex_lock(&ff->mutex); | |
| 219 | − ret = erase_effect(dev, effect_id, file); | |
| 220 | − mutex_unlock(&ff->mutex); | |
| 221 | − | |
| 222 | − return ret; | |
| 210 | + guard(mutex)(&ff->mutex); | |
| 211 | + return erase_effect(dev, effect_id, file); | |
| 223 | 212 | } |
| 224 | 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 | 229 | dev_dbg(&dev->dev, "flushing now\n"); |
| 241 | 230 | |
| 242 | − mutex_lock(&ff->mutex); | |
| 231 | + guard(mutex)(&ff->mutex); | |
| 243 | 232 | |
| 244 | 233 | for (i = 0; i < ff->max_effects; i++) |
| 245 | 234 | erase_effect(dev, i, file); |
| 246 | 235 | |
| 247 | − mutex_unlock(&ff->mutex); | |
| 248 | − | |
| 249 | 236 | return 0; |
| 250 | 237 | } |
| 251 | 238 | EXPORT_SYMBOL_GPL(input_ff_flush); |
| @@ -303,8 +290,6 @@ EXPORT_SYMBOL_GPL(input_ff_event); · 51 unmodified lines | ||
| 303 | 290 | */ |
| 304 | 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 | 293 | int i; |
| 309 | 294 | |
| 310 | 295 | if (!max_effects) { |
| @@ -317,25 +302,19 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects) · 6 unmodified lines | ||
| 317 | 302 | return -EINVAL; |
| 318 | 303 | } |
| 319 | 304 | |
| 320 | − ff_dev_size = struct_size(ff, effect_owners, max_effects); | |
| 321 | − if (ff_dev_size == SIZE_MAX) /* overflow */ | |
| 322 | − return -EINVAL; | |
| 323 | − | |
| 324 | − ff = kzalloc(ff_dev_size, GFP_KERNEL); | |
| 305 | + struct ff_device *ff __free(kfree) = | |
| 306 | + kzalloc(struct_size(ff, effect_owners, max_effects), | |
| 307 | + GFP_KERNEL); | |
| 325 | 308 | if (!ff) |
| 326 | 309 | return -ENOMEM; |
| 327 | 310 | |
| 328 | − ff->effects = kcalloc(max_effects, sizeof(struct ff_effect), | |
| 329 | − GFP_KERNEL); | |
| 330 | − if (!ff->effects) { | |
| 331 | − kfree(ff); | |
| 311 | + ff->effects = kcalloc(max_effects, sizeof(*ff->effects), GFP_KERNEL); | |
| 312 | + if (!ff->effects) | |
| 332 | 313 | return -ENOMEM; |
| 333 | − } | |
| 334 | 314 | |
| 335 | 315 | ff->max_effects = max_effects; |
| 336 | 316 | mutex_init(&ff->mutex); |
| 337 | 317 | |
| 338 | − dev->ff = ff; | |
| 339 | 318 | dev->flush = input_ff_flush; |
| 340 | 319 | dev->event = input_ff_event; |
| 341 | 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 | 327 | if (test_bit(FF_PERIODIC, ff->ffbit)) |
| 349 | 328 | __set_bit(FF_RUMBLE, dev->ffbit); |
| 350 | 329 | |
| 330 | + dev->ff = no_free_ptr(ff); | |
| 331 | + | |
| 351 | 332 | return 0; |
| 352 | 333 | } |
| 353 | 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 | 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 | /* |
| @@ -465,7 +463,7 @@ static int ml_ff_upload(struct input_dev *dev, · 51 unmodified lines | ||
| 465 | 463 | struct ml_device *ml = dev->ff->private; |
| 466 | 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 | 468 | if (test_bit(FF_EFFECT_STARTED, &state->flags)) { |
| 471 | 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 | 475 | ml_schedule_timer(ml); |
| 478 | 476 | } |
| 479 | 477 | |
| 480 | − spin_unlock_irq(&dev->event_lock); | |
| 481 | − | |
| 482 | 478 | return 0; |
| 483 | 479 | } |
| 484 | 480 | |
| @@ -507,12 +503,11 @@ static void ml_ff_destroy(struct ff_device *ff) · 22 unmodified lines | ||
| 507 | 503 | int input_ff_create_memless(struct input_dev *dev, void *data, |
| 508 | 504 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)) |
| 509 | 505 | { |
| 510 | − struct ml_device *ml; | |
| 511 | 506 | struct ff_device *ff; |
| 512 | 507 | int error; |
| 513 | 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 | 511 | if (!ml) |
| 517 | 512 | return -ENOMEM; |
| 518 | 513 | |
| @@ -525,13 +520,10 @@ int input_ff_create_memless(struct input_dev *dev, void *data, · 6 unmodified lines | ||
| 525 | 520 | set_bit(FF_GAIN, dev->ffbit); |
| 526 | 521 | |
| 527 | 522 | error = input_ff_create(dev, FF_MEMLESS_EFFECTS); |
| 528 | − if (error) { | |
| 529 | − kfree(ml); | |
| 523 | + if (error) | |
| 530 | 524 | return error; |
| 531 | − } | |
| 532 | 525 | |
| 533 | 526 | ff = dev->ff; |
| 534 | − ff->private = ml; | |
| 535 | 527 | ff->upload = ml_ff_upload; |
| 536 | 528 | ff->playback = ml_ff_playback; |
| 537 | 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 | 540 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) |
| 549 | 541 | ml->states[i].effect = &ff->effects[i]; |
| 550 | 542 | |
| 543 | + ff->private = no_free_ptr(ml); | |
| 544 | + | |
| 551 | 545 | return 0; |
| 552 | 546 | } |
| 553 | 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 | 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,21 +86,18 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, · 27 unmodified lines | ||
| 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 | |
| @@ -285,14 +282,10 @@ void input_mt_drop_unused(struct input_dev *dev) · 178 unmodified lines | ||
| 285 | 282 | struct input_mt *mt = dev->mt; |
| 286 | 283 | |
| 287 | 284 | if (mt) { |
| 288 | − unsigned long flags; | |
| 289 | − | |
| 290 | − spin_lock_irqsave(&dev->event_lock, flags); | |
| 285 | + guard(spinlock_irqsave)(&dev->event_lock); | |
| 291 | 286 | |
| 292 | 287 | __input_mt_drop_unused(dev, mt); |
| 293 | 288 | mt->frame++; |
| 294 | − | |
| 295 | − spin_unlock_irqrestore(&dev->event_lock, flags); | |
| 296 | 289 | } |
| 297 | 290 | } |
| 298 | 291 | EXPORT_SYMBOL(input_mt_drop_unused); |
| @@ -339,11 +332,8 @@ void input_mt_sync_frame(struct input_dev *dev) · 40 unmodified lines | ||
| 339 | 332 | return; |
| 340 | 333 | |
| 341 | 334 | if (mt->flags & INPUT_MT_DROP_UNUSED) { |
| 342 | − unsigned long flags; | |
| 343 | − | |
| 344 | − spin_lock_irqsave(&dev->event_lock, flags); | |
| 335 | + guard(spinlock_irqsave)(&dev->event_lock); | |
| 345 | 336 | __input_mt_drop_unused(dev, mt); |
| 346 | − spin_unlock_irqrestore(&dev->event_lock, flags); | |
| 347 | 337 | } |
| 348 | 338 | |
| 349 | 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 | 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 | |
| @@ -172,8 +172,6 @@ static ssize_t input_dev_set_poll_interval(struct device *dev, · 3 unmodified lines | ||
| 172 | 172 | input_dev_poller_queue_work(poller); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | − mutex_unlock(&input->mutex); | |
| 176 | − | |
| 177 | 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 | 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 | 134 | |
| 133 | − rcu_read_unlock(); | |
| 134 | − | |
| 135 | 135 | /* trigger auto repeat for key events */ |
| 136 | 136 | if (test_bit(EV_REP, dev->evbit) && test_bit(EV_KEY, dev->evbit)) { |
| 137 | 137 | for (v = vals; v != vals + count; v++) { |
| @@ -390,13 +390,9 @@ void input_handle_event(struct input_dev *dev, · 252 unmodified lines | ||
| 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); |
| @@ -417,18 +413,15 @@ void input_inject_event(struct input_handle *handle, · 14 unmodified lines | ||
| 417 | 413 | { |
| 418 | 414 | struct input_dev *dev = handle->dev; |
| 419 | 415 | struct input_handle *grab; |
| 420 | − unsigned long flags; | |
| 421 | 416 | |
| 422 | 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 | 421 | grab = rcu_dereference(dev->grab); |
| 427 | 422 | if (!grab || grab == handle) |
| 428 | 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 | 427 | EXPORT_SYMBOL(input_inject_event); |
| @@ -526,22 +519,15 @@ EXPORT_SYMBOL(input_copy_abs); · 91 unmodified lines | ||
| 526 | 519 | int input_grab_device(struct input_handle *handle) |
| 527 | 520 | { |
| 528 | 521 | struct input_dev *dev = handle->dev; |
| 529 | − int retval; | |
| 530 | 522 | |
| 531 | − retval = mutex_lock_interruptible(&dev->mutex); | |
| 532 | − if (retval) | |
| 533 | − return retval; | |
| 523 | + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { | |
| 524 | + if (dev->grab) | |
| 525 | + return -EBUSY; | |
| 534 | 526 | |
| 535 | − if (dev->grab) { | |
| 536 | − retval = -EBUSY; | |
| 537 | − goto out; | |
| 527 | + rcu_assign_pointer(dev->grab, handle); | |
| 538 | 528 | } |
| 539 | 529 | |
| 540 | − rcu_assign_pointer(dev->grab, handle); | |
| 541 | − | |
| 542 | − out: | |
| 543 | − mutex_unlock(&dev->mutex); | |
| 544 | − return retval; | |
| 530 | + return 0; | |
| 545 | 531 | } |
| 546 | 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 | 563 | struct input_dev *dev = handle->dev; |
| 578 | 564 | |
| 579 | − mutex_lock(&dev->mutex); | |
| 565 | + guard(mutex)(&dev->mutex); | |
| 580 | 566 | __input_release_device(handle); |
| 581 | − mutex_unlock(&dev->mutex); | |
| 582 | 567 | } |
| 583 | 568 | EXPORT_SYMBOL(input_release_device); |
| 584 | 569 | |
| @@ -592,67 +577,57 @@ EXPORT_SYMBOL(input_release_device); · 7 unmodified lines | ||
| 592 | 577 | int input_open_device(struct input_handle *handle) |
| 593 | 578 | { |
| 594 | 579 | struct input_dev *dev = handle->dev; |
| 595 | − int retval; | |
| 596 | − | |
| 597 | − retval = mutex_lock_interruptible(&dev->mutex); | |
| 598 | − if (retval) | |
| 599 | − return retval; | |
| 600 | − | |
| 601 | − if (dev->going_away) { | |
| 602 | − retval = -ENODEV; | |
| 603 | − goto out; | |
| 604 | − } | |
| 580 | + int error; | |
| 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) | |
| 609 | − goto out; | |
| 586 | + handle->open++; | |
| 610 | 587 | |
| 611 | − if (dev->users++ || dev->inhibited) { | |
| 612 | − /* | |
| 613 | − * Device is already opened and/or inhibited, | |
| 614 | − * so we can exit immediately and report success. | |
| 615 | − */ | |
| 616 | − goto out; | |
| 617 | − } | |
| 588 | + if (handle->handler->passive_observer) | |
| 589 | + return 0; | |
| 618 | 590 | |
| 619 | − if (dev->open) { | |
| 620 | − retval = dev->open(dev); | |
| 621 | − if (retval) { | |
| 622 | − dev->users--; | |
| 623 | − handle->open--; | |
| 591 | + if (dev->users++ || dev->inhibited) { | |
| 624 | 592 | /* |
| 625 | − * Make sure we are not delivering any more events | |
| 626 | − * through this handle | |
| 593 | + * Device is already opened and/or inhibited, | |
| 594 | + * so we can exit immediately and report success. | |
| 627 | 595 | */ |
| 628 | − synchronize_rcu(); | |
| 629 | − goto out; | |
| 596 | + return 0; | |
| 630 | 597 | } |
| 631 | − } | |
| 632 | 598 | |
| 633 | − if (dev->poller) | |
| 634 | − input_dev_poller_start(dev->poller); | |
| 599 | + if (dev->open) { | |
| 600 | + error = dev->open(dev); | |
| 601 | + if (error) { | |
| 602 | + dev->users--; | |
| 603 | + handle->open--; | |
| 604 | + /* | |
| 605 | + * Make sure we are not delivering any more | |
| 606 | + * events through this handle. | |
| 607 | + */ | |
| 608 | + synchronize_rcu(); | |
| 609 | + return error; | |
| 610 | + } | |
| 611 | + } | |
| 635 | 612 | |
| 636 | − out: | |
| 637 | − mutex_unlock(&dev->mutex); | |
| 638 | − return retval; | |
| 613 | + if (dev->poller) | |
| 614 | + input_dev_poller_start(dev->poller); | |
| 615 | + } | |
| 616 | + | |
| 617 | + return 0; | |
| 639 | 618 | } |
| 640 | 619 | EXPORT_SYMBOL(input_open_device); |
| 641 | 620 | |
| 642 | 621 | int input_flush_device(struct input_handle *handle, struct file *file) |
| 643 | 622 | { |
| 644 | 623 | struct input_dev *dev = handle->dev; |
| 645 | − int retval; | |
| 646 | 624 | |
| 647 | − retval = mutex_lock_interruptible(&dev->mutex); | |
| 648 | − if (retval) | |
| 649 | − return retval; | |
| 650 | − | |
| 651 | − if (dev->flush) | |
| 652 | − retval = dev->flush(dev, file); | |
| 625 | + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { | |
| 626 | + if (dev->flush) | |
| 627 | + return dev->flush(dev, file); | |
| 628 | + } | |
| 653 | 629 | |
| 654 | − mutex_unlock(&dev->mutex); | |
| 655 | − return retval; | |
| 630 | + return 0; | |
| 656 | 631 | } |
| 657 | 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 | 643 | struct input_dev *dev = handle->dev; |
| 669 | 644 | |
| 670 | − mutex_lock(&dev->mutex); | |
| 645 | + guard(mutex)(&dev->mutex); | |
| 671 | 646 | |
| 672 | 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 | 664 | synchronize_rcu(); |
| 690 | 665 | } |
| 691 | − | |
| 692 | − mutex_unlock(&dev->mutex); | |
| 693 | 666 | } |
| 694 | 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 | 699 | * not to protect access to dev->going_away but rather to ensure |
| 727 | 700 | * that there are no threads in the middle of input_open_device() |
| 728 | 701 | */ |
| 729 | − mutex_lock(&dev->mutex); | |
| 730 | − dev->going_away = true; | |
| 731 | − mutex_unlock(&dev->mutex); | |
| 702 | + scoped_guard(mutex, &dev->mutex) | |
| 703 | + dev->going_away = true; | |
| 732 | 704 | |
| 733 | − spin_lock_irq(&dev->event_lock); | |
| 705 | + guard(spinlock_irq)(&dev->event_lock); | |
| 734 | 706 | |
| 735 | 707 | /* |
| 736 | 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 | 716 | list_for_each_entry(handle, &dev->h_list, d_node) |
| 745 | 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 | 872 | int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke) |
| 903 | 873 | { |
| 904 | − unsigned long flags; | |
| 905 | − int retval; | |
| 874 | + guard(spinlock_irqsave)(&dev->event_lock); | |
| 906 | 875 | |
| 907 | − spin_lock_irqsave(&dev->event_lock, flags); | |
| 908 | − retval = dev->getkeycode(dev, ke); | |
| 909 | − spin_unlock_irqrestore(&dev->event_lock, flags); | |
| 910 | − | |
| 911 | − return retval; | |
| 876 | + return dev->getkeycode(dev, ke); | |
| 912 | 877 | } |
| 913 | 878 | EXPORT_SYMBOL(input_get_keycode); |
| 914 | 879 | |
| @@ -923,18 +888,17 @@ EXPORT_SYMBOL(input_get_keycode); · 8 unmodified lines | ||
| 923 | 888 | int input_set_keycode(struct input_dev *dev, |
| 924 | 889 | const struct input_keymap_entry *ke) |
| 925 | 890 | { |
| 926 | − unsigned long flags; | |
| 927 | 891 | unsigned int old_keycode; |
| 928 | − int retval; | |
| 892 | + int error; | |
| 929 | 893 | |
| 930 | 894 | if (ke->keycode > KEY_MAX) |
| 931 | 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); | |
| 936 | − if (retval) | |
| 937 | − goto out; | |
| 899 | + error = dev->setkeycode(dev, ke, &old_keycode); | |
| 900 | + if (error) | |
| 901 | + return error; | |
| 938 | 902 | |
| 939 | 903 | /* Make sure KEY_RESERVED did not get enabled. */ |
| 940 | 904 | __clear_bit(KEY_RESERVED, dev->keybit); |
| @@ -962,10 +926,7 @@ int input_set_keycode(struct input_dev *dev, · 21 unmodified lines | ||
| 962 | 926 | EV_SYN, SYN_REPORT, 1); |
| 963 | 927 | } |
| 964 | 928 | |
| 965 | − out: | |
| 966 | − spin_unlock_irqrestore(&dev->event_lock, flags); | |
| 967 | − | |
| 968 | − return retval; | |
| 929 | + return 0; | |
| 969 | 930 | } |
| 970 | 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 | 1761 | void input_reset_device(struct input_dev *dev) |
| 1801 | 1762 | { |
| 1802 | − unsigned long flags; | |
| 1803 | − | |
| 1804 | − mutex_lock(&dev->mutex); | |
| 1805 | − spin_lock_irqsave(&dev->event_lock, flags); | |
| 1763 | + guard(mutex)(&dev->mutex); | |
| 1764 | + guard(spinlock_irqsave)(&dev->event_lock); | |
| 1806 | 1765 | |
| 1807 | 1766 | input_dev_toggle(dev, true); |
| 1808 | 1767 | if (input_dev_release_keys(dev)) |
| 1809 | 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 | 1770 | EXPORT_SYMBOL(input_reset_device); |
| 1815 | 1771 | |
| 1816 | 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 | 1776 | if (dev->inhibited) |
| 1821 | − goto out; | |
| 1777 | + return 0; | |
| 1822 | 1778 | |
| 1823 | 1779 | if (dev->users) { |
| 1824 | 1780 | if (dev->close) |
| @@ -1827,54 +1783,50 @@ static int input_inhibit_device(struct input_dev *dev) · 2 unmodified lines | ||
| 1827 | 1783 | input_dev_poller_stop(dev->poller); |
| 1828 | 1784 | } |
| 1829 | 1785 | |
| 1830 | − spin_lock_irq(&dev->event_lock); | |
| 1831 | − input_mt_release_slots(dev); | |
| 1832 | − input_dev_release_keys(dev); | |
| 1833 | − input_handle_event(dev, EV_SYN, SYN_REPORT, 1); | |
| 1834 | − input_dev_toggle(dev, false); | |
| 1835 | − spin_unlock_irq(&dev->event_lock); | |
| 1786 | + scoped_guard(spinlock_irq, &dev->event_lock) { | |
| 1787 | + input_mt_release_slots(dev); | |
| 1788 | + input_dev_release_keys(dev); | |
| 1789 | + input_handle_event(dev, EV_SYN, SYN_REPORT, 1); | |
| 1790 | + input_dev_toggle(dev, false); | |
| 1791 | + } | |
| 1836 | 1792 | |
| 1837 | 1793 | dev->inhibited = true; |
| 1838 | 1794 | |
| 1839 | −out: | |
| 1840 | − mutex_unlock(&dev->mutex); | |
| 1841 | 1795 | return 0; |
| 1842 | 1796 | } |
| 1843 | 1797 | |
| 1844 | 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 | 1804 | if (!dev->inhibited) |
| 1851 | − goto out; | |
| 1805 | + return 0; | |
| 1852 | 1806 | |
| 1853 | 1807 | if (dev->users) { |
| 1854 | 1808 | if (dev->open) { |
| 1855 | − ret = dev->open(dev); | |
| 1856 | − if (ret) | |
| 1857 | − goto out; | |
| 1809 | + error = dev->open(dev); | |
| 1810 | + if (error) | |
| 1811 | + return error; | |
| 1858 | 1812 | } |
| 1859 | 1813 | if (dev->poller) |
| 1860 | 1814 | input_dev_poller_start(dev->poller); |
| 1861 | 1815 | } |
| 1862 | 1816 | |
| 1863 | 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: | |
| 1869 | − mutex_unlock(&dev->mutex); | |
| 1870 | − return ret; | |
| 1819 | + scoped_guard(spinlock_irq, &dev->event_lock) | |
| 1820 | + input_dev_toggle(dev, true); | |
| 1821 | + | |
| 1822 | + return 0; | |
| 1871 | 1823 | } |
| 1872 | 1824 | |
| 1873 | 1825 | static int input_dev_suspend(struct device *dev) |
| 1874 | 1826 | { |
| 1875 | 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 | 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 | 1838 | /* Turn off LEDs and sounds, if any are active. */ |
| 1887 | 1839 | input_dev_toggle(input_dev, false); |
| 1888 | 1840 | |
| 1889 | − spin_unlock_irq(&input_dev->event_lock); | |
| 1890 | − | |
| 1891 | 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 | 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 | 1850 | /* Restore state of LEDs and sounds, if any were active. */ |
| 1901 | 1851 | input_dev_toggle(input_dev, true); |
| 1902 | 1852 | |
| 1903 | − spin_unlock_irq(&input_dev->event_lock); | |
| 1904 | − | |
| 1905 | 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 | 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 | 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 | 1866 | if (input_dev_release_keys(input_dev)) |
| 1919 | 1867 | input_handle_event(input_dev, EV_SYN, SYN_REPORT, 1); |
| 1920 | 1868 | |
| 1921 | − spin_unlock_irq(&input_dev->event_lock); | |
| 1922 | − | |
| 1923 | 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 | 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 | 1878 | /* Turn off LEDs and sounds, if any are active. */ |
| 1933 | 1879 | input_dev_toggle(input_dev, false); |
| 1934 | 1880 | |
| 1935 | − spin_unlock_irq(&input_dev->event_lock); | |
| 1936 | − | |
| 1937 | 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 | 2219 | input_disconnect_device(dev); |
| 2276 | 2220 | |
| 2277 | − mutex_lock(&input_mutex); | |
| 2278 | − | |
| 2279 | − list_for_each_entry_safe(handle, next, &dev->h_list, d_node) | |
| 2280 | − handle->handler->disconnect(handle); | |
| 2281 | − WARN_ON(!list_empty(&dev->h_list)); | |
| 2221 | + scoped_guard(mutex, &input_mutex) { | |
| 2222 | + list_for_each_entry_safe(handle, next, &dev->h_list, d_node) | |
| 2223 | + handle->handler->disconnect(handle); | |
| 2224 | + WARN_ON(!list_empty(&dev->h_list)); | |
| 2282 | 2225 | |
| 2283 | − del_timer_sync(&dev->timer); | |
| 2284 | − list_del_init(&dev->node); | |
| 2226 | + del_timer_sync(&dev->timer); | |
| 2227 | + list_del_init(&dev->node); | |
| 2285 | 2228 | |
| 2286 | − input_wakeup_procfs_readers(); | |
| 2287 | − | |
| 2288 | − mutex_unlock(&input_mutex); | |
| 2229 | + input_wakeup_procfs_readers(); | |
| 2230 | + } | |
| 2289 | 2231 | |
| 2290 | 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 | 2250 | static void input_repeat_key(struct timer_list *t) |
| 2309 | 2251 | { |
| 2310 | 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 | 2256 | if (!dev->inhibited && |
| 2316 | 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 | 2265 | mod_timer(&dev->timer, jiffies + |
| 2325 | 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 | 2309 | if (!vals) |
| 2371 | 2310 | return -ENOMEM; |
| 2372 | 2311 | |
| 2373 | − spin_lock_irq(&dev->event_lock); | |
| 2374 | − dev->max_vals = max_vals; | |
| 2375 | − swap(dev->vals, vals); | |
| 2376 | − spin_unlock_irq(&dev->event_lock); | |
| 2312 | + scoped_guard(spinlock_irq, &dev->event_lock) { | |
| 2313 | + dev->max_vals = max_vals; | |
| 2314 | + swap(dev->vals, vals); | |
| 2315 | + } | |
| 2377 | 2316 | |
| 2378 | 2317 | /* Because of swap() above, this frees the old vals memory */ |
| 2379 | 2318 | kfree(vals); |
| @@ -2465,18 +2404,15 @@ int input_register_device(struct input_dev *dev) · 85 unmodified lines | ||
| 2465 | 2404 | path ? path : "N/A"); |
| 2466 | 2405 | kfree(path); |
| 2467 | 2406 | |
| 2468 | − error = mutex_lock_interruptible(&input_mutex); | |
| 2469 | − if (error) | |
| 2470 | − goto err_device_del; | |
| 2407 | + error = -EINTR; | |
| 2408 | + scoped_cond_guard(mutex_intr, goto err_device_del, &input_mutex) { | |
| 2409 | + list_add_tail(&dev->node, &input_dev_list); | |
| 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) | |
| 2475 | − input_attach_handler(dev, handler); | |
| 2476 | − | |
| 2477 | − input_wakeup_procfs_readers(); | |
| 2478 | − | |
| 2479 | − mutex_unlock(&input_mutex); | |
| 2414 | + input_wakeup_procfs_readers(); | |
| 2415 | + } | |
| 2480 | 2416 | |
| 2481 | 2417 | if (dev->devres_managed) { |
| 2482 | 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 | 2492 | if (error) |
| 2557 | 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); | |
| 2562 | − if (error) | |
| 2563 | − return error; | |
| 2564 | − | |
| 2565 | − list_add_tail(&handler->node, &input_handler_list); | |
| 2498 | + list_add_tail(&handler->node, &input_handler_list); | |
| 2566 | 2499 | |
| 2567 | − list_for_each_entry(dev, &input_dev_list, node) | |
| 2568 | − input_attach_handler(dev, handler); | |
| 2500 | + list_for_each_entry(dev, &input_dev_list, node) | |
| 2501 | + input_attach_handler(dev, handler); | |
| 2569 | 2502 | |
| 2570 | − input_wakeup_procfs_readers(); | |
| 2503 | + input_wakeup_procfs_readers(); | |
| 2504 | + } | |
| 2571 | 2505 | |
| 2572 | − mutex_unlock(&input_mutex); | |
| 2573 | 2506 | return 0; |
| 2574 | 2507 | } |
| 2575 | 2508 | EXPORT_SYMBOL(input_register_handler); |
| @@ -2585,7 +2518,7 @@ void input_unregister_handler(struct input_handler *handler) · 9 unmodified lines | ||
| 2585 | 2518 | { |
| 2586 | 2519 | struct input_handle *handle, *next; |
| 2587 | 2520 | |
| 2588 | − mutex_lock(&input_mutex); | |
| 2521 | + guard(mutex)(&input_mutex); | |
| 2589 | 2522 | |
| 2590 | 2523 | list_for_each_entry_safe(handle, next, &handler->h_list, h_node) |
| 2591 | 2524 | handler->disconnect(handle); |
| @@ -2594,8 +2527,6 @@ void input_unregister_handler(struct input_handler *handler) · 2 unmodified lines | ||
| 2594 | 2527 | list_del_init(&handler->node); |
| 2595 | 2528 | |
| 2596 | 2529 | input_wakeup_procfs_readers(); |
| 2597 | − | |
| 2598 | − mutex_unlock(&input_mutex); | |
| 2599 | 2530 | } |
| 2600 | 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 | 2546 | int (*fn)(struct input_handle *, void *)) |
| 2616 | 2547 | { |
| 2617 | 2548 | struct input_handle *handle; |
| 2618 | − int retval = 0; | |
| 2549 | + int retval; | |
| 2619 | 2550 | |
| 2620 | − rcu_read_lock(); | |
| 2551 | + guard(rcu)(); | |
| 2621 | 2552 | |
| 2622 | 2553 | list_for_each_entry_rcu(handle, &handler->h_list, h_node) { |
| 2623 | 2554 | retval = fn(handle, data); |
| 2624 | 2555 | if (retval) |
| 2625 | − break; | |
| 2556 | + return retval; | |
| 2626 | 2557 | } |
| 2627 | 2558 | |
| 2628 | − rcu_read_unlock(); | |
| 2629 | − | |
| 2630 | − return retval; | |
| 2559 | + return 0; | |
| 2631 | 2560 | } |
| 2632 | 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 | 2645 | struct input_handler *handler = handle->handler; |
| 2717 | 2646 | struct input_dev *dev = handle->dev; |
| 2718 | − int error; | |
| 2719 | 2647 | |
| 2720 | 2648 | input_handle_setup_event_handler(handle); |
| 2721 | 2649 | /* |
| 2722 | 2650 | * We take dev->mutex here to prevent race with |
| 2723 | 2651 | * input_release_device(). |
| 2724 | 2652 | */ |
| 2725 | − error = mutex_lock_interruptible(&dev->mutex); | |
| 2726 | − if (error) | |
| 2727 | − return error; | |
| 2728 | − | |
| 2729 | − /* | |
| 2730 | − * Filters go to the head of the list, normal handlers | |
| 2731 | − * to the tail. | |
| 2732 | − */ | |
| 2733 | − if (handler->filter) | |
| 2734 | − list_add_rcu(&handle->d_node, &dev->h_list); | |
| 2735 | − else | |
| 2736 | − list_add_tail_rcu(&handle->d_node, &dev->h_list); | |
| 2737 | − | |
| 2738 | − mutex_unlock(&dev->mutex); | |
| 2653 | + scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { | |
| 2654 | + /* | |
| 2655 | + * Filters go to the head of the list, normal handlers | |
| 2656 | + * to the tail. | |
| 2657 | + */ | |
| 2658 | + if (handler->filter) | |
| 2659 | + list_add_rcu(&handle->d_node, &dev->h_list); | |
| 2660 | + else | |
| 2661 | + list_add_tail_rcu(&handle->d_node, &dev->h_list); | |
| 2662 | + } | |
| 2739 | 2663 | |
| 2740 | 2664 | /* |
| 2741 | 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 | 2696 | * Take dev->mutex to prevent race with input_release_device(). |
| 2773 | 2697 | */ |
| 2774 | − mutex_lock(&dev->mutex); | |
| 2775 | − list_del_rcu(&handle->d_node); | |
| 2776 | − mutex_unlock(&dev->mutex); | |
| 2698 | + scoped_guard(mutex, &dev->mutex) | |
| 2699 | + list_del_rcu(&handle->d_node); | |
| 2777 | 2700 | |
| 2778 | 2701 | synchronize_rcu(); |
| 2779 | 2702 | } |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 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 | |
| @@ -677,7 +678,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) · 657 unmodified lines | ||
| 677 | 678 | case 48: /* Ambiguous */ |
| 678 | 679 | if (j == 14) { /* ID length 14*3 -> FFP */ |
| 679 | 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 | 682 | } else |
| 682 | 683 | sw->type = SW_ID_PP; |
| 683 | 684 | break; |
| @@ -150,6 +150,7 @@ static const struct xpad_device { · 149 unmodified lines | ||
| 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 }, |
| @@ -305,6 +306,7 @@ static const struct xpad_device { · 149 unmodified lines | ||
| 305 | 306 | { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 }, |
| 306 | 307 | { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 }, |
| 307 | 308 | { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 }, |
| 309 | + { 0x1a86, 0xe310, "QH Electronics Controller", 0, XTYPE_XBOX360 }, | |
| 308 | 310 | { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, |
| 309 | 311 | { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, |
| 310 | 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 | 375 | { 0x294b, 0x3303, "Snakebyte GAMEPAD BASE X", 0, XTYPE_XBOXONE }, |
| 374 | 376 | { 0x294b, 0x3404, "Snakebyte GAMEPAD RGB X", 0, XTYPE_XBOXONE }, |
| 375 | 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 | 379 | { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, |
| 378 | 380 | { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, |
| 379 | 381 | { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, |
| 380 | 382 | { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, |
| 381 | 383 | { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, |
| 382 | 384 | { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 }, |
| 385 | + { 0x31e3, 0x1230, "Wooting Two HE (ARM)", 0, XTYPE_XBOX360 }, | |
| 383 | 386 | { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, |
| 384 | 387 | { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, |
| 385 | 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 | 391 | { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, |
| 387 | 392 | { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, |
| 388 | 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 | 519 | XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ |
| 515 | 520 | XPAD_XBOX360_VENDOR(0x17ef), /* Lenovo */ |
| 516 | 521 | XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */ |
| 522 | + XPAD_XBOX360_VENDOR(0x1a86), /* QH Electronics */ | |
| 517 | 523 | XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */ |
| 518 | 524 | XPAD_XBOX360_VENDOR(0x20d6), /* PowerA controllers */ |
| 519 | 525 | XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA controllers */ |
| @@ -530,6 +536,7 @@ static const struct usb_device_id xpad_table[] = { · 10 unmodified lines | ||
| 530 | 536 | XPAD_XBOX360_VENDOR(0x2f24), /* GameSir controllers */ |
| 531 | 537 | XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ |
| 532 | 538 | XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ |
| 539 | + XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */ | |
| 533 | 540 | XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ |
| 534 | 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 | 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 | |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/delay.h> |
| 15 | 15 | #include <linux/input.h> |
| 16 | 16 | #include <linux/slab.h> |
| 17 | +#include <linux/string_choices.h> | |
| 17 | 18 | #include <linux/bitops.h> |
| 18 | 19 | |
| 19 | 20 | struct dir685_touchkeys { |
| @@ -48,7 +49,7 @@ static irqreturn_t dir685_tk_irq_thread(int irq, void *data) · 28 unmodified lines | ||
| 48 | 49 | changed = tk->cur_key ^ key; |
| 49 | 50 | for_each_set_bit(i, &changed, num_bits) { |
| 50 | 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 | 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 | 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. */ |
| @@ -269,7 +270,7 @@ static void process_keys(struct lm8323_chip *lm) · 242 unmodified lines | ||
| 269 | 270 | unsigned short keycode = lm->keymap[key]; |
| 270 | 271 | |
| 271 | 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 | 275 | if (lm->kp_enabled) { |
| 275 | 276 | input_event(lm->idev, EV_MSC, MSC_SCAN, key); |
| @@ -18,6 +18,7 @@ · 17 unmodified lines | ||
| 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> |
| @@ -94,7 +95,7 @@ static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on) · 70 unmodified lines | ||
| 94 | 95 | on << MAINCTRL1_BIASEN_SHIFT); |
| 95 | 96 | if (error) { |
| 96 | 97 | dev_err(haptic->dev, "failed to %s bias: %d\n", |
| 97 | − on ? "enable" : "disable", error); | |
| 98 | + str_enable_disable(on), error); | |
| 98 | 99 | return error; |
| 99 | 100 | } |
| 100 | 101 | |
| @@ -38,6 +38,8 @@ · 37 unmodified lines | ||
| 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 | { |
| @@ -148,8 +150,20 @@ static void mma8450_close(struct input_dev *input) · 104 unmodified lines | ||
| 148 | 150 | */ |
| 149 | 151 | static int mma8450_probe(struct i2c_client *c) |
| 150 | 152 | { |
| 153 | + struct i2c_adapter *adapter = c->adapter; | |
| 151 | 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 | 168 | input = devm_input_allocate_device(&c->dev); |
| 155 | 169 | if (!input) |
| @@ -187,6 +187,12 @@ static int bbnsm_pwrkey_probe(struct platform_device *pdev) · 186 unmodified lines | ||
| 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); |
| @@ -223,6 +229,8 @@ static struct platform_driver bbnsm_pwrkey_driver = { · 30 unmodified lines | ||
| 223 | 229 | .of_match_table = bbnsm_pwrkey_ids, |
| 224 | 230 | }, |
| 225 | 231 | .probe = bbnsm_pwrkey_probe, |
| 232 | + .remove = bbnsm_pwrkey_remove, | |
| 233 | + | |
| 226 | 234 | }; |
| 227 | 235 | module_platform_driver(bbnsm_pwrkey_driver); |
| 228 | 236 | |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 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 | |
| @@ -44,7 +45,7 @@ static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on) · 24 unmodified lines | ||
| 44 | 45 | if (error) { |
| 45 | 46 | dev_err(haptic->dev, |
| 46 | 47 | "failed to switch regulator %s: %d\n", |
| 47 | − on ? "on" : "off", error); | |
| 48 | + str_on_off(on), error); | |
| 48 | 49 | return error; |
| 49 | 50 | } |
| 50 | 51 | |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 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> |
| @@ -199,7 +200,7 @@ static int elan_set_power(struct elan_tp_data *data, bool on) · 165 unmodified lines | ||
| 199 | 200 | } while (--repeat > 0); |
| 200 | 201 | |
| 201 | 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 | 204 | return error; |
| 204 | 205 | } |
| 205 | 206 | |
| @@ -665,23 +665,50 @@ static void synaptics_pt_stop(struct serio *serio) · 664 unmodified lines | ||
| 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 | |
| @@ -720,6 +747,8 @@ static void synaptics_pt_create(struct psmouse *psmouse) · 32 unmodified lines | ||
| 720 | 747 | serio->write = synaptics_pt_write; |
| 721 | 748 | serio->start = synaptics_pt_start; |
| 722 | 749 | serio->stop = synaptics_pt_stop; |
| 750 | + serio->open = synaptics_pt_open; | |
| 751 | + serio->close = synaptics_pt_close; | |
| 723 | 752 | serio->parent = psmouse->ps2dev.serio; |
| 724 | 753 | |
| 725 | 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 | 1246 | if (SYN_CAP_PASS_THROUGH(priv->info.capabilities) && |
| 1218 | 1247 | synaptics_is_pt_packet(psmouse->packet)) { |
| 1219 | − if (priv->pt_port) | |
| 1220 | − synaptics_pass_pt_packet(priv->pt_port, | |
| 1221 | − psmouse->packet); | |
| 1222 | − } else | |
| 1248 | + synaptics_pass_pt_packet(priv, psmouse->packet); | |
| 1249 | + } else { | |
| 1223 | 1250 | synaptics_process_packet(psmouse); |
| 1251 | + } | |
| 1224 | 1252 | |
| 1225 | 1253 | return PSMOUSE_FULL_PACKET; |
| 1226 | 1254 | } |
| @@ -188,6 +188,7 @@ struct synaptics_data { · 187 unmodified lines | ||
| 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 |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | ||
| 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 | |
| @@ -102,7 +103,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) · 73 unmodified lines | ||
| 102 | 103 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down); |
| 103 | 104 | |
| 104 | 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 | 108 | if (down) { |
| 108 | 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 | − | |