mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
Input: fix locking in force-feedback core
The newly added event_lock spinlock in the input core disallows sleeping and therefore using mutexes in event handlers. Convert force-feedback core to rely on event_lock instead of mutex to protect slots allocated for fore-feedback effects. The original mutex is still used to serialize uploading and erasing of effects. Reported-by: Anssi Hannula <anssi.hannula@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
4bbff7e408
commit
656acd2bbc
@ -166,8 +166,10 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
spin_lock_irq(&dev->event_lock);
|
||||
ff->effects[id] = *effect;
|
||||
ff->effect_owners[id] = file;
|
||||
spin_unlock_irq(&dev->event_lock);
|
||||
|
||||
out:
|
||||
mutex_unlock(&ff->mutex);
|
||||
@ -189,15 +191,21 @@ static int erase_effect(struct input_dev *dev, int effect_id,
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
spin_lock_irq(&dev->event_lock);
|
||||
ff->playback(dev, effect_id, 0);
|
||||
ff->effect_owners[effect_id] = NULL;
|
||||
spin_unlock_irq(&dev->event_lock);
|
||||
|
||||
if (ff->erase) {
|
||||
error = ff->erase(dev, effect_id);
|
||||
if (error)
|
||||
if (error) {
|
||||
spin_lock_irq(&dev->event_lock);
|
||||
ff->effect_owners[effect_id] = file;
|
||||
spin_unlock_irq(&dev->event_lock);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
ff->effect_owners[effect_id] = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -263,8 +271,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
|
||||
if (type != EV_FF)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&ff->mutex);
|
||||
|
||||
switch (code) {
|
||||
case FF_GAIN:
|
||||
if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff)
|
||||
@ -286,7 +292,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
|
||||
break;
|
||||
}
|
||||
|
||||
mutex_unlock(&ff->mutex);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(input_ff_event);
|
||||
|
Loading…
Reference in New Issue
Block a user