Input: uinput - avoid FF flush when destroying device
Subsystems (2)
Dmitry Torokhov
maintainerPATCH 1/6 Input: uinput - avoid FF flush when destroying device
Normally, when input device supporting force feedback effects is being destroyed, we try to "flush" currently playing effects, so that the physical device does not continue vibrating (or executing other effects). Unfortunately this does not work well for uinput as flushing of the effects deadlocks with the destroy action:
- if device is being destroyed because the file descriptor is being closed, then there is noone to even service FF requests;
- if device is being destroyed because userspace sent UI_DEV_DESTROY, while theoretically it could be possible to service FF requests, userspace is unlikely to do so (they'd need to make sure FF handling happens on a separate thread) even if kernel solves the issue with FF ioctls deadlocking with UI_DEV_DESTROY ioctl on udev->mutex.
To avoid lockups like the one below, let's install a custom input device flush handler, and avoid trying to flush force feedback effects when we destroying the device, and instead rely on uinput to shut off the device properly.
NMI watchdog: Watchdog detected hard LOCKUP on cpu 3
...
<<EOE>> [<ffffffff817a0307>] _raw_spin_lock_irqsave+0x37/0x40
[<ffffffff810e633d>] complete+0x1d/0x50 [<ffffffffa00ba08c>] uinput_request_done+0x3c/0x40 [uinput] [<ffffffffa00ba587>] uinput_request_submit.part.7+0x47/0xb0 [uinput] [<ffffffffa00bb62b>] uinput_dev_erase_effect+0x5b/0x76 [uinput] [<ffffffff815d91ad>] erase_effect+0xad/0xf0 [<ffffffff815d929d>] flush_effects+0x4d/0x90 [<ffffffff815d4cc0>] input_flush_device+0x40/0x60 [<ffffffff815daf1c>] evdev_cleanup+0xac/0xc0 [<ffffffff815daf5b>] evdev_disconnect+0x2b/0x60 [<ffffffff815d74ac>] __input_unregister_device+0xac/0x150 [<ffffffff815d75f7>] input_unregister_device+0x47/0x70 [<ffffffffa00bac45>] uinput_destroy_device+0xb5/0xc0 [uinput] [<ffffffffa00bb2de>] uinput_ioctl_handler.isra.9+0x65e/0x740 [uinput] [<ffffffff811231ab>] ? do_futex+0x12b/0xad0 [<ffffffffa00bb3f8>] uinput_ioctl+0x18/0x20 [uinput] [<ffffffff81241248>] do_vfs_ioctl+0x298/0x480 [<ffffffff81337553>] ? security_file_ioctl+0x43/0x60 [<ffffffff812414a9>] SyS_ioctl+0x79/0x90 [<ffffffff817a04ee>] entry_SYSCALL_64_fastpath+0x12/0x71
--- drivers/input/ff-core.c | 13 ++++++++++--- drivers/input/misc/uinput.c | 18 ++++++++++++++++++ include/linux/input.h | 1 + 3 files changed, 29 insertions(+), 3 deletions(-)
drivers/input/ff-core.c +10 -3
@@ -237,9 +237,15 @@ int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file)EXPORT_SYMBOL_GPL (input_ff_erase);/* -* flush_effects - erase all effects owned by a file handle +* input_ff_flush - erase all effects owned by a file handle +* @dev: input device to erase effect from +* @file: purported owner of the effects +* +* This function erases all force-feedback effects associated with +* the given owner from specified device. Note that @file may be %NULL, +* in which case all effects will be erased. */ -static int flush_effects (struct input_dev *dev,struct file *file) +int input_ff_flush (struct input_dev *dev,struct file *file) {struct ff_device *ff = dev->ff;int i;
@@ -255,6 +261,7 @@ static int flush_effects(struct input_dev *dev, struct file *file)return 0 ; } +EXPORT_SYMBOL_GPL (input_ff_flush);/** * input_ff_event() - generic handler for force-feedback events
@@ -343,7 +350,7 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects)mutex_init (&ff->mutex); dev->ff = ff; - dev->flush = flush_effects; + dev->flush = input_ff_flush; dev->event = input_ff_event;__set_bit (EV_FF , dev->evbit);
drivers/input/misc/uinput.c +18 -0
@@ -230,6 +230,18 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)return uinput_request_submit (udev, &request); } +static int uinput_dev_flush (struct input_dev *dev,struct file *file) +{ +/* +* If we are called with file == NULL that means we are tearing +* down the device, and therefore we can not handle FF erase +* requests: either we are handling UI_DEV_DESTROY (and holding +* the udev->mutex), or the file descriptor is closed and there is +* nobody on the other side anymore. +*/ +return file ?input_ff_flush (dev, file) :0 ; +} +static void uinput_destroy_device (struct uinput_device *udev) {const char *name, *phys;
@@ -297,6 +309,12 @@ static int uinput_create_device(struct uinput_device *udev) dev->ff->playback = uinput_dev_playback; dev->ff->set_gain = uinput_dev_set_gain; dev->ff->set_autocenter = uinput_dev_set_autocenter; +/* +* The standard input_ff_flush() implementation does +* not quite work for uinput as we can't reasonably +* handle FF requests during device teardown. +*/ + dev->flush = uinput_dev_flush; } error =input_register_device (udev->dev);
include/linux/input.h +1 -0
@@ -537,6 +537,7 @@ int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code,int input_ff_upload (struct input_dev *dev,struct ff_effect *effect,struct file *file);int input_ff_erase (struct input_dev *dev,int effect_id,struct file *file); +int input_ff_flush (struct input_dev *dev,struct file *file);int input_ff_create_memless (struct input_dev *dev,void *data,int (*play_effect)(struct input_dev *,void *,struct ff_effect *));
Signature · 1 line
2.14.1.581.gf28d330327-goog
Dmitry Torokhov
maintainerPATCH 3/6 Input: uinput - allow FF requests to time out
Previously uinput force feedback requests waited for the userspace indefinitely, which caused users to block when uinput server process become unresponsive. Let's establish a 30 seconds deadline for servicing upload and erase force feedback effect actions, so that users have a chance to abort stuck requests.
--- drivers/input/misc/uinput.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/input/misc/uinput.c +5 -1
@@ -149,7 +149,11 @@ static int uinput_request_submit(struct uinput_device *udev,if (retval) goto out; -wait_for_completion (&request->done); +if (!wait_for_completion_timeout (&request->done,30 *HZ )) { + retval = -ETIMEDOUT ; + goto out; + } + retval = request->retval; out:
Signature · 1 line
2.14.1.581.gf28d330327-goog
Dmitry Torokhov
maintainerPATCH 5/6 Input: uinput - remove uinput_allocate_device()
In reply to Dmitry TorokhovThere is no need for this wrapper; let's use input_allocate_device() directly, and complete initialization in uinput_create_device().
--- drivers/input/misc/uinput.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
drivers/input/misc/uinput.c +10 -18
@@ -324,6 +324,10 @@ static int uinput_create_device(struct uinput_device *udev) dev->flush = uinput_dev_flush; } + dev->event = uinput_dev_event; + +input_set_drvdata (udev->dev, udev); + error =input_register_device (udev->dev);if (error) goto fail2;
@@ -406,18 +410,6 @@ static int uinput_validate_absbits(struct input_dev *dev)return 0 ; } -static int uinput_allocate_device (struct uinput_device *udev) -{ - udev->dev =input_allocate_device (); -if (!udev->dev) -return -ENOMEM ; - - udev->dev->event = uinput_dev_event; -input_set_drvdata (udev->dev, udev); - -return 0 ; -} -static int uinput_dev_setup (struct uinput_device *udev,struct uinput_setup __user *arg) {
@@ -493,9 +485,9 @@ static int uinput_setup_device_legacy(struct uinput_device *udev,return -EINVAL ;if (!udev->dev) { - retval =uinput_allocate_device (udev); -if (retval) -return retval; + udev->dev =input_allocate_device (); +if (!udev->dev) +return -ENOMEM ; } dev = udev->dev;
@@ -826,9 +818,9 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,return retval;if (!udev->dev) { - retval =uinput_allocate_device (udev); -if (retval) - goto out; + udev->dev =input_allocate_device (); +if (!udev->dev) +return -ENOMEM ; }switch (cmd) {
Signature · 1 line
2.14.1.581.gf28d330327-goog
Dmitry Torokhov
maintainerPATCH 6/6 Input: uinput - fold header into the driver proper
In reply to Dmitry TorokhovThere is nothing in the uinput kernel header that is of use to anyone in the kernel besides the uinput driver itself, so let's fold it into the driver code (leaving uapi part intact).
--- drivers/input/misc/uinput.c | 40 +++++++++++++++++++++- include/linux/uinput.h | 81 --------------------------------------------- 2 files changed, 39 insertions(+), 82 deletions(-) delete mode 100644 include/linux/uinput.h
drivers/input/misc/uinput.c +39 -1
@@ -31,6 +31,7 @@* 0.1 20/06/2002 * - first public version */ +#include <uapi/linux/uinput.h> #include <linux/poll.h> #include <linux/sched.h> #include <linux/slab.h>
@@ -38,10 +39,47 @@#include <linux/init.h> #include <linux/fs.h> #include <linux/miscdevice.h> -#include <linux/uinput.h> #include <linux/input/mt.h> #include "../input-compat.h" +#define UINPUT_NAME "uinput" +#define UINPUT_BUFFER_SIZE 16 +#define UINPUT_NUM_REQUESTS 16 + +enum uinput_state {UIST_NEW_DEVICE ,UIST_SETUP_COMPLETE ,UIST_CREATED }; + +struct uinput_request { +unsigned int id; +unsigned int code;/* UI_FF_UPLOAD, UI_FF_ERASE */ + +int retval; +struct completion done; + +union { +unsigned int effect_id; +struct { +struct ff_effect *effect; +struct ff_effect *old; + } upload; + } u; +}; + +struct uinput_device { +struct input_dev *dev; +struct mutex mutex; +enum uinput_state state; +wait_queue_head_t waitq; +unsigned char ready; +unsigned char head; +unsigned char tail; +struct input_event buff[UINPUT_BUFFER_SIZE ]; +unsigned int ff_effects_max; + +struct uinput_request *requests[UINPUT_NUM_REQUESTS ]; +wait_queue_head_t requests_waitq; +spinlock_t requests_lock; +}; +static int uinput_dev_event (struct input_dev *dev,unsigned int type,unsigned int code,int value) {
include/linux/uinput.h deleted +0 -81
81 lines not on this page · raw message
Signature · 1 line
2.14.1.581.gf28d330327-goog
Dmitry Torokhov
maintainerPATCH 2/6 Input: uinput - avoid crash when sending FF request to device going away
In reply to Dmitry TorokhovIf FF request comes in while uinput device is going away, uinput_request_send() will fail with -ENODEV, and uinput_request_submit() will attempt to mark the slot as unused by calling uinput_request_done(). Unfortunately in this case we haven't initialized request->done completion yet, and we get a crash:
[ 39.402036] BUG: spinlock bad magic on CPU#1, fftest/3108 [ 39.402046] lock: 0xffff88006a93bb00, .magic: 00000000, .owner: /39, .owner_cpu: 1217155072 [ 39.402055] CPU: 1 PID: 3108 Comm: fftest Tainted: G W 4.13.0+ #15 [ 39.402059] Hardware name: LENOVO 20HQS0EG02/20HQS0EG02, BIOS N1MET37W (1.22 ) 07/04/2017 [ 39.402064] 0000000000000086 f0fad82f3ceaa120 ffff88006a93b9a0 ffffffff9de941bb [ 39.402077] ffff88026df8ae00 ffff88006a93bb00 ffff88006a93b9c0 ffffffff9dca62b7 [ 39.402088] ffff88006a93bb00 ffff88006a93baf8 ffff88006a93b9e0 ffffffff9dca62e7 [ 39.402099] Call Trace: [ 39.402112] [<ffffffff9de941bb>] dump_stack+0x4d/0x63 [ 39.402123] [<ffffffff9dca62b7>] spin_dump+0x97/0x9c [ 39.402130] [<ffffffff9dca62e7>] spin_bug+0x2b/0x2d [ 39.402138] [<ffffffff9dca6373>] do_raw_spin_lock+0x28/0xfd [ 39.402147] [<ffffffff9e3055cd>] _raw_spin_lock_irqsave+0x19/0x1f [ 39.402154] [<ffffffff9dca05b7>] complete+0x1d/0x48 [ 39.402162] [<ffffffffc04f30af>] 0xffffffffc04f30af [ 39.402167] [<ffffffffc04f468c>] 0xffffffffc04f468c [ 39.402177] [<ffffffff9dd59c16>] ? __slab_free+0x22f/0x359 [ 39.402184] [<ffffffff9dcc13e9>] ? tk_clock_read+0xc/0xe [ 39.402189] [<ffffffffc04f471f>] 0xffffffffc04f471f [ 39.402195] [<ffffffff9dc9ffe5>] ? __wake_up+0x44/0x4b [ 39.402200] [<ffffffffc04f3240>] ? 0xffffffffc04f3240 [ 39.402207] [<ffffffff9e0f57f3>] erase_effect+0xa1/0xd2 [ 39.402214] [<ffffffff9e0f58c6>] input_ff_flush+0x43/0x5c [ 39.402219] [<ffffffffc04f32ad>] 0xffffffffc04f32ad [ 39.402227] [<ffffffff9e0f174f>] input_flush_device+0x3d/0x51 [ 39.402234] [<ffffffff9e0f69ae>] evdev_flush+0x49/0x5c [ 39.402243] [<ffffffff9dd62d6e>] filp_close+0x3f/0x65 [ 39.402253] [<ffffffff9dd7dcf7>] put_files_struct+0x66/0xc1 [ 39.402261] [<ffffffff9dd7ddeb>] exit_files+0x47/0x4e [ 39.402270] [<ffffffff9dc6b329>] do_exit+0x483/0x969 [ 39.402278] [<ffffffff9dc73211>] ? recalc_sigpending_tsk+0x3d/0x44 [ 39.402285] [<ffffffff9dc6c7a2>] do_group_exit+0x42/0xb0 [ 39.402293] [<ffffffff9dc767e1>] get_signal+0x58d/0x5bf [ 39.402300] [<ffffffff9dc03701>] do_signal+0x37/0x53e [ 39.402307] [<ffffffff9e0f8401>] ? evdev_ioctl_handler+0xac8/0xb04 [ 39.402314] [<ffffffff9e0f8464>] ? evdev_ioctl+0x10/0x12 [ 39.402321] [<ffffffff9dd74cfa>] ? do_vfs_ioctl+0x42e/0x501 [ 39.402328] [<ffffffff9dc0170e>] prepare_exit_to_usermode+0x66/0x90 [ 39.402333] [<ffffffff9dc0181b>] syscall_return_slowpath+0xe3/0xec [ 39.402339] [<ffffffff9e305b7b>] int_ret_from_sys_call+0x25/0x8f
While we could solve this by simply initializing the completion earlier, we are better off rearranging the code a bit so we avoid calling complete() on requests that we did not send out. This patch consolidates marking request slots as free in one place (in uinput_request_submit(), the same place where we acquire them) and having everyone else simply signal completion of the requests.
--- drivers/input/misc/uinput.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/input/misc/uinput.c +21 -18
@@ -98,14 +98,15 @@ static int uinput_request_reserve_slot(struct uinput_device *udev, uinput_request_alloc_id(udev, request)); } -static void uinput_request_done (struct uinput_device *udev, -struct uinput_request *request) +static void uinput_request_release_slot (struct uinput_device *udev, +unsigned int id) {/* Mark slot as available */ - udev->requests[request->id] =NULL ; -wake_up (&udev->requests_waitq); +spin_lock (&udev->requests_lock); + udev->requests[id] =NULL ; +spin_unlock (&udev->requests_lock); -complete (&request->done); +wake_up (&udev->requests_waitq); } static int uinput_request_send(struct uinput_device *udev,
@@ -138,20 +139,22 @@ static int uinput_request_send(struct uinput_device *udev,static int uinput_request_submit (struct uinput_device *udev,struct uinput_request *request) { -int error; +int retval; - error =uinput_request_reserve_slot (udev, request); -if (error) -return error; + retval =uinput_request_reserve_slot (udev, request); +if (retval) +return retval; - error =uinput_request_send (udev, request); -if (error) { -uinput_request_done (udev, request); -return error; - } + retval =uinput_request_send (udev, request); +if (retval) + goto out;wait_for_completion (&request->done); -return request->retval; + retval = request->retval; + + out: +uinput_request_release_slot (udev, request->id); +return retval; }/*
@@ -169,7 +172,7 @@ static void uinput_flush_requests(struct uinput_device *udev) request = udev->requests[i];if (request) { request->retval = -ENODEV ; -uinput_request_done (udev, request); +complete (&request->done); } }
@@ -957,7 +960,7 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, } req->retval = ff_up.retval; -uinput_request_done (udev, req); +complete (&req->done); goto out;case UI_END_FF_ERASE :
@@ -973,7 +976,7 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, } req->retval = ff_erase.retval; -uinput_request_done (udev, req); +complete (&req->done); goto out; }
Signature · 1 line
2.14.1.581.gf28d330327-goog
Dmitry Torokhov
maintainerPATCH 4/6 Input: uinput - fix coding style in uinput_ioctl_handler()
In reply to Dmitry Torokhov"case"s in switch statement were indented extra level, let's fix that.
--- drivers/input/misc/uinput.c | 231 ++++++++++++++++++++++---------------------- 1 file changed, 115 insertions(+), 116 deletions(-)
drivers/input/misc/uinput.c +115 -116
@@ -832,156 +832,155 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, }switch (cmd) { -case UI_GET_VERSION : -if (put_user (UINPUT_VERSION , - (unsigned int __user *)p)) - retval = -EFAULT ; - goto out; +case UI_GET_VERSION : +if (put_user (UINPUT_VERSION , (unsigned int __user *)p)) + retval = -EFAULT ; + goto out; -case UI_DEV_CREATE : - retval =uinput_create_device (udev); - goto out; +case UI_DEV_CREATE : + retval =uinput_create_device (udev); + goto out; -case UI_DEV_DESTROY : -uinput_destroy_device (udev); - goto out; +case UI_DEV_DESTROY : +uinput_destroy_device (udev); + goto out; -case UI_DEV_SETUP : - retval =uinput_dev_setup (udev, p); - goto out; +case UI_DEV_SETUP : + retval =uinput_dev_setup (udev, p); + goto out; -/* UI_ABS_SETUP is handled in the variable size ioctls */ +/* UI_ABS_SETUP is handled in the variable size ioctls */ -case UI_SET_EVBIT : - retval =uinput_set_bit (arg, evbit,EV_MAX ); - goto out; +case UI_SET_EVBIT : + retval =uinput_set_bit (arg, evbit,EV_MAX ); + goto out; -case UI_SET_KEYBIT : - retval =uinput_set_bit (arg, keybit,KEY_MAX ); - goto out; +case UI_SET_KEYBIT : + retval =uinput_set_bit (arg, keybit,KEY_MAX ); + goto out; -case UI_SET_RELBIT : - retval =uinput_set_bit (arg, relbit,REL_MAX ); - goto out; +case UI_SET_RELBIT : + retval =uinput_set_bit (arg, relbit,REL_MAX ); + goto out; -case UI_SET_ABSBIT : - retval =uinput_set_bit (arg, absbit,ABS_MAX ); - goto out; +case UI_SET_ABSBIT : + retval =uinput_set_bit (arg, absbit,ABS_MAX ); + goto out; -case UI_SET_MSCBIT : - retval =uinput_set_bit (arg, mscbit,MSC_MAX ); - goto out; +case UI_SET_MSCBIT : + retval =uinput_set_bit (arg, mscbit,MSC_MAX ); + goto out; -case UI_SET_LEDBIT : - retval =uinput_set_bit (arg, ledbit,LED_MAX ); - goto out; +case UI_SET_LEDBIT : + retval =uinput_set_bit (arg, ledbit,LED_MAX ); + goto out; + +case UI_SET_SNDBIT : + retval =uinput_set_bit (arg, sndbit,SND_MAX ); + goto out; + +case UI_SET_FFBIT : + retval =uinput_set_bit (arg, ffbit,FF_MAX ); + goto out; + +case UI_SET_SWBIT : + retval =uinput_set_bit (arg, swbit,SW_MAX ); + goto out; + +case UI_SET_PROPBIT : + retval =uinput_set_bit (arg, propbit,INPUT_PROP_MAX ); + goto out; -case UI_SET_SNDBIT : - retval =uinput_set_bit (arg, sndbit,SND_MAX ); +case UI_SET_PHYS : +if (udev->state ==UIST_CREATED ) { + retval = -EINVAL ; goto out; + } -case UI_SET_FFBIT : - retval =uinput_set_bit (arg, ffbit,FF_MAX ); + phys =strndup_user (p,1024 ); +if (IS_ERR (phys)) { + retval =PTR_ERR (phys); goto out; + } + +kfree (udev->dev->phys); + udev->dev->phys = phys; + goto out; -case UI_SET_SWBIT : - retval =uinput_set_bit (arg, swbit,SW_MAX ); +case UI_BEGIN_FF_UPLOAD : + retval =uinput_ff_upload_from_user (p, &ff_up); +if (retval) goto out; -case UI_SET_PROPBIT : - retval =uinput_set_bit (arg, propbit,INPUT_PROP_MAX ); + req =uinput_request_find (udev, ff_up.request_id); +if (!req || req->code !=UI_FF_UPLOAD || + !req->u.upload.effect) { + retval = -EINVAL ; goto out; + } -case UI_SET_PHYS : -if (udev->state ==UIST_CREATED ) { - retval = -EINVAL ; - goto out; - } + ff_up.retval =0 ; + ff_up.effect = *req->u.upload.effect; +if (req->u.upload.old) + ff_up.old = *req->u.upload.old; +else +memset (&ff_up.old,0 ,sizeof (struct ff_effect )); - phys =strndup_user (p,1024 ); -if (IS_ERR (phys)) { - retval =PTR_ERR (phys); - goto out; - } + retval =uinput_ff_upload_to_user (p, &ff_up); + goto out; -kfree (udev->dev->phys); - udev->dev->phys = phys; +case UI_BEGIN_FF_ERASE : +if (copy_from_user (&ff_erase, p,sizeof (ff_erase))) { + retval = -EFAULT ; goto out; + } -case UI_BEGIN_FF_UPLOAD : - retval =uinput_ff_upload_from_user (p, &ff_up); -if (retval) - goto out; - - req =uinput_request_find (udev, ff_up.request_id); -if (!req || req->code !=UI_FF_UPLOAD || - !req->u.upload.effect) { - retval = -EINVAL ; - goto out; - } - - ff_up.retval =0 ; - ff_up.effect = *req->u.upload.effect; -if (req->u.upload.old) - ff_up.old = *req->u.upload.old; -else -memset (&ff_up.old,0 ,sizeof (struct ff_effect )); - - retval =uinput_ff_upload_to_user (p, &ff_up); + req =uinput_request_find (udev, ff_erase.request_id); +if (!req || req->code !=UI_FF_ERASE ) { + retval = -EINVAL ; goto out; + } -case UI_BEGIN_FF_ERASE : -if (copy_from_user (&ff_erase, p,sizeof (ff_erase))) { - retval = -EFAULT ; - goto out; - } - - req =uinput_request_find (udev, ff_erase.request_id); -if (!req || req->code !=UI_FF_ERASE ) { - retval = -EINVAL ; - goto out; - } - - ff_erase.retval =0 ; - ff_erase.effect_id = req->u.effect_id; -if (copy_to_user (p, &ff_erase,sizeof (ff_erase))) { - retval = -EFAULT ; - goto out; - } - + ff_erase.retval =0 ; + ff_erase.effect_id = req->u.effect_id; +if (copy_to_user (p, &ff_erase,sizeof (ff_erase))) { + retval = -EFAULT ; goto out; + } -case UI_END_FF_UPLOAD : - retval =uinput_ff_upload_from_user (p, &ff_up); -if (retval) - goto out; + goto out; - req =uinput_request_find (udev, ff_up.request_id); -if (!req || req->code !=UI_FF_UPLOAD || - !req->u.upload.effect) { - retval = -EINVAL ; - goto out; - } +case UI_END_FF_UPLOAD : + retval =uinput_ff_upload_from_user (p, &ff_up); +if (retval) + goto out; - req->retval = ff_up.retval; -complete (&req->done); + req =uinput_request_find (udev, ff_up.request_id); +if (!req || req->code !=UI_FF_UPLOAD || + !req->u.upload.effect) { + retval = -EINVAL ; goto out; + } -case UI_END_FF_ERASE : -if (copy_from_user (&ff_erase, p,sizeof (ff_erase))) { - retval = -EFAULT ; - goto out; - } + req->retval = ff_up.retval; +complete (&req->done); + goto out; - req =uinput_request_find (udev, ff_erase.request_id); -if (!req || req->code !=UI_FF_ERASE ) { - retval = -EINVAL ; - goto out; - } +case UI_END_FF_ERASE : +if (copy_from_user (&ff_erase, p,sizeof (ff_erase))) { + retval = -EFAULT ; + goto out; + } - req->retval = ff_erase.retval; -complete (&req->done); + req =uinput_request_find (udev, ff_erase.request_id); +if (!req || req->code !=UI_FF_ERASE ) { + retval = -EINVAL ; goto out; + } + + req->retval = ff_erase.retval; +complete (&req->done); + goto out; } size =_IOC_SIZE (cmd);
Signature · 1 line
2.14.1.581.gf28d330327-goog