Skip to content

Commit 88e969f

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

22 files changed

+275
-468
lines changed

drivers/input/Kconfig

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,6 @@ config INPUT_EVDEV
152152
To compile this driver as a module, choose M here: the
153153
module will be called evdev.
154154

155-
config INPUT_EVBUG
156-
tristate "Event debugging"
157-
help
158-
Say Y here if you have a problem with the input subsystem and
159-
want all events (keypresses, mouse movements), to be output to
160-
the system log. While this is useful for debugging, it's also
161-
a security threat - your keypresses include your passwords, of
162-
course.
163-
164-
If unsure, say N.
165-
166-
To compile this driver as a module, choose M here: the
167-
module will be called evbug.
168-
169155
config INPUT_KUNIT_TEST
170156
tristate "KUnit tests for Input" if !KUNIT_ALL_TESTS
171157
depends on INPUT && KUNIT

drivers/input/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ obj-$(CONFIG_INPUT_LEDS) += input-leds.o
1818
obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
1919
obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
2020
obj-$(CONFIG_INPUT_EVDEV) += evdev.o
21-
obj-$(CONFIG_INPUT_EVBUG) += evbug.o
2221

2322
obj-$(CONFIG_INPUT_KEYBOARD) += keyboard/
2423
obj-$(CONFIG_INPUT_MOUSE) += mouse/

drivers/input/evbug.c

Lines changed: 0 additions & 100 deletions
This file was deleted.

drivers/input/ff-core.c

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
9393
{
9494
struct ff_device *ff = dev->ff;
9595
struct ff_effect *old;
96-
int ret = 0;
96+
int error;
9797
int id;
9898

9999
if (!test_bit(EV_FF, dev->evbit))
@@ -114,53 +114,47 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
114114
}
115115

116116
if (!test_bit(effect->type, ff->ffbit)) {
117-
ret = compat_effect(ff, effect);
118-
if (ret)
119-
return ret;
117+
error = compat_effect(ff, effect);
118+
if (error)
119+
return error;
120120
}
121121

122-
mutex_lock(&ff->mutex);
122+
guard(mutex)(&ff->mutex);
123123

124124
if (effect->id == -1) {
125125
for (id = 0; id < ff->max_effects; id++)
126126
if (!ff->effect_owners[id])
127127
break;
128128

129-
if (id >= ff->max_effects) {
130-
ret = -ENOSPC;
131-
goto out;
132-
}
129+
if (id >= ff->max_effects)
130+
return -ENOSPC;
133131

134132
effect->id = id;
135133
old = NULL;
136134

137135
} else {
138136
id = effect->id;
139137

140-
ret = check_effect_access(ff, id, file);
141-
if (ret)
142-
goto out;
138+
error = check_effect_access(ff, id, file);
139+
if (error)
140+
return error;
143141

144142
old = &ff->effects[id];
145143

146-
if (!check_effects_compatible(effect, old)) {
147-
ret = -EINVAL;
148-
goto out;
149-
}
144+
if (!check_effects_compatible(effect, old))
145+
return -EINVAL;
150146
}
151147

152-
ret = ff->upload(dev, effect, old);
153-
if (ret)
154-
goto out;
148+
error = ff->upload(dev, effect, old);
149+
if (error)
150+
return error;
155151

156-
spin_lock_irq(&dev->event_lock);
157-
ff->effects[id] = *effect;
158-
ff->effect_owners[id] = file;
159-
spin_unlock_irq(&dev->event_lock);
152+
scoped_guard(spinlock_irq, &dev->event_lock) {
153+
ff->effects[id] = *effect;
154+
ff->effect_owners[id] = file;
155+
}
160156

161-
out:
162-
mutex_unlock(&ff->mutex);
163-
return ret;
157+
return 0;
164158
}
165159
EXPORT_SYMBOL_GPL(input_ff_upload);
166160

@@ -178,17 +172,16 @@ static int erase_effect(struct input_dev *dev, int effect_id,
178172
if (error)
179173
return error;
180174

181-
spin_lock_irq(&dev->event_lock);
182-
ff->playback(dev, effect_id, 0);
183-
ff->effect_owners[effect_id] = NULL;
184-
spin_unlock_irq(&dev->event_lock);
175+
scoped_guard(spinlock_irq, &dev->event_lock) {
176+
ff->playback(dev, effect_id, 0);
177+
ff->effect_owners[effect_id] = NULL;
178+
}
185179

186180
if (ff->erase) {
187181
error = ff->erase(dev, effect_id);
188182
if (error) {
189-
spin_lock_irq(&dev->event_lock);
190-
ff->effect_owners[effect_id] = file;
191-
spin_unlock_irq(&dev->event_lock);
183+
scoped_guard(spinlock_irq, &dev->event_lock)
184+
ff->effect_owners[effect_id] = file;
192185

193186
return error;
194187
}
@@ -210,16 +203,12 @@ static int erase_effect(struct input_dev *dev, int effect_id,
210203
int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file)
211204
{
212205
struct ff_device *ff = dev->ff;
213-
int ret;
214206

215207
if (!test_bit(EV_FF, dev->evbit))
216208
return -ENOSYS;
217209

218-
mutex_lock(&ff->mutex);
219-
ret = erase_effect(dev, effect_id, file);
220-
mutex_unlock(&ff->mutex);
221-
222-
return ret;
210+
guard(mutex)(&ff->mutex);
211+
return erase_effect(dev, effect_id, file);
223212
}
224213
EXPORT_SYMBOL_GPL(input_ff_erase);
225214

@@ -239,13 +228,11 @@ int input_ff_flush(struct input_dev *dev, struct file *file)
239228

240229
dev_dbg(&dev->dev, "flushing now\n");
241230

242-
mutex_lock(&ff->mutex);
231+
guard(mutex)(&ff->mutex);
243232

244233
for (i = 0; i < ff->max_effects; i++)
245234
erase_effect(dev, i, file);
246235

247-
mutex_unlock(&ff->mutex);
248-
249236
return 0;
250237
}
251238
EXPORT_SYMBOL_GPL(input_ff_flush);
@@ -303,8 +290,6 @@ EXPORT_SYMBOL_GPL(input_ff_event);
303290
*/
304291
int input_ff_create(struct input_dev *dev, unsigned int max_effects)
305292
{
306-
struct ff_device *ff;
307-
size_t ff_dev_size;
308293
int i;
309294

310295
if (!max_effects) {
@@ -317,25 +302,19 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects)
317302
return -EINVAL;
318303
}
319304

320-
ff_dev_size = struct_size(ff, effect_owners, max_effects);
321-
if (ff_dev_size == SIZE_MAX) /* overflow */
322-
return -EINVAL;
323-
324-
ff = kzalloc(ff_dev_size, GFP_KERNEL);
305+
struct ff_device *ff __free(kfree) =
306+
kzalloc(struct_size(ff, effect_owners, max_effects),
307+
GFP_KERNEL);
325308
if (!ff)
326309
return -ENOMEM;
327310

328-
ff->effects = kcalloc(max_effects, sizeof(struct ff_effect),
329-
GFP_KERNEL);
330-
if (!ff->effects) {
331-
kfree(ff);
311+
ff->effects = kcalloc(max_effects, sizeof(*ff->effects), GFP_KERNEL);
312+
if (!ff->effects)
332313
return -ENOMEM;
333-
}
334314

335315
ff->max_effects = max_effects;
336316
mutex_init(&ff->mutex);
337317

338-
dev->ff = ff;
339318
dev->flush = input_ff_flush;
340319
dev->event = input_ff_event;
341320
__set_bit(EV_FF, dev->evbit);
@@ -348,6 +327,8 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects)
348327
if (test_bit(FF_PERIODIC, ff->ffbit))
349328
__set_bit(FF_RUMBLE, dev->ffbit);
350329

330+
dev->ff = no_free_ptr(ff);
331+
351332
return 0;
352333
}
353334
EXPORT_SYMBOL_GPL(input_ff_create);

drivers/input/ff-memless.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,11 @@ static void ml_effect_timer(struct timer_list *t)
401401
{
402402
struct ml_device *ml = from_timer(ml, t, timer);
403403
struct input_dev *dev = ml->dev;
404-
unsigned long flags;
405404

406405
pr_debug("timer: updating effects\n");
407406

408-
spin_lock_irqsave(&dev->event_lock, flags);
407+
guard(spinlock_irqsave)(&dev->event_lock);
409408
ml_play_effects(ml);
410-
spin_unlock_irqrestore(&dev->event_lock, flags);
411409
}
412410

413411
/*
@@ -465,7 +463,7 @@ static int ml_ff_upload(struct input_dev *dev,
465463
struct ml_device *ml = dev->ff->private;
466464
struct ml_effect_state *state = &ml->states[effect->id];
467465

468-
spin_lock_irq(&dev->event_lock);
466+
guard(spinlock_irq)(&dev->event_lock);
469467

470468
if (test_bit(FF_EFFECT_STARTED, &state->flags)) {
471469
__clear_bit(FF_EFFECT_PLAYING, &state->flags);
@@ -477,8 +475,6 @@ static int ml_ff_upload(struct input_dev *dev,
477475
ml_schedule_timer(ml);
478476
}
479477

480-
spin_unlock_irq(&dev->event_lock);
481-
482478
return 0;
483479
}
484480

@@ -507,12 +503,11 @@ static void ml_ff_destroy(struct ff_device *ff)
507503
int input_ff_create_memless(struct input_dev *dev, void *data,
508504
int (*play_effect)(struct input_dev *, void *, struct ff_effect *))
509505
{
510-
struct ml_device *ml;
511506
struct ff_device *ff;
512507
int error;
513508
int i;
514509

515-
ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL);
510+
struct ml_device *ml __free(kfree) = kzalloc(sizeof(*ml), GFP_KERNEL);
516511
if (!ml)
517512
return -ENOMEM;
518513

@@ -525,13 +520,10 @@ int input_ff_create_memless(struct input_dev *dev, void *data,
525520
set_bit(FF_GAIN, dev->ffbit);
526521

527522
error = input_ff_create(dev, FF_MEMLESS_EFFECTS);
528-
if (error) {
529-
kfree(ml);
523+
if (error)
530524
return error;
531-
}
532525

533526
ff = dev->ff;
534-
ff->private = ml;
535527
ff->upload = ml_ff_upload;
536528
ff->playback = ml_ff_playback;
537529
ff->set_gain = ml_ff_set_gain;
@@ -548,6 +540,8 @@ int input_ff_create_memless(struct input_dev *dev, void *data,
548540
for (i = 0; i < FF_MEMLESS_EFFECTS; i++)
549541
ml->states[i].effect = &ff->effects[i];
550542

543+
ff->private = no_free_ptr(ml);
544+
551545
return 0;
552546
}
553547
EXPORT_SYMBOL_GPL(input_ff_create_memless);

0 commit comments

Comments
 (0)