Skip to content

Commit e1441b9

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: fix locking in force-feedback core Input: add KEY_MEDIA_REPEAT definition
2 parents 70c8505 + 656acd2 commit e1441b9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

drivers/input/ff-core.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
166166
if (ret)
167167
goto out;
168168

169+
spin_lock_irq(&dev->event_lock);
169170
ff->effects[id] = *effect;
170171
ff->effect_owners[id] = file;
172+
spin_unlock_irq(&dev->event_lock);
171173

172174
out:
173175
mutex_unlock(&ff->mutex);
@@ -189,16 +191,22 @@ static int erase_effect(struct input_dev *dev, int effect_id,
189191
if (error)
190192
return error;
191193

194+
spin_lock_irq(&dev->event_lock);
192195
ff->playback(dev, effect_id, 0);
196+
ff->effect_owners[effect_id] = NULL;
197+
spin_unlock_irq(&dev->event_lock);
193198

194199
if (ff->erase) {
195200
error = ff->erase(dev, effect_id);
196-
if (error)
201+
if (error) {
202+
spin_lock_irq(&dev->event_lock);
203+
ff->effect_owners[effect_id] = file;
204+
spin_unlock_irq(&dev->event_lock);
205+
197206
return error;
207+
}
198208
}
199209

200-
ff->effect_owners[effect_id] = NULL;
201-
202210
return 0;
203211
}
204212

@@ -263,8 +271,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
263271
if (type != EV_FF)
264272
return 0;
265273

266-
mutex_lock(&ff->mutex);
267-
268274
switch (code) {
269275
case FF_GAIN:
270276
if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff)
@@ -286,7 +292,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
286292
break;
287293
}
288294

289-
mutex_unlock(&ff->mutex);
290295
return 0;
291296
}
292297
EXPORT_SYMBOL_GPL(input_ff_event);

include/linux/input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ struct input_absinfo {
534534

535535
#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */
536536
#define KEY_FRAMEFORWARD 0x1b5
537-
538537
#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */
538+
#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */
539539

540540
#define KEY_DEL_EOL 0x1c0
541541
#define KEY_DEL_EOS 0x1c1

0 commit comments

Comments
 (0)