Input: Refactor evdev 32bit compat to be shareable with uinput
PATCH 1/1 Input: Refactor evdev 32bit compat to be shareable with uinput
Currently, evdev has working 32bit compatibility and uinput does not. uinput needs the input_event code that evdev uses, so let's refactor it so it can be shared.
---
drivers/input/Makefile | 2 drivers/input/evdev.c | 118 ++----------------------------------------- drivers/input/input_compat.c | 89 ++++++++++++++++++++++++++++++++ drivers/input/misc/uinput.c | 23 ++++++-- include/linux/input_compat.h | 61 ++++++++++++++++++++++ 5 files changed, 175 insertions(+), 118 deletions(-)
drivers/input/Makefile +1 -1
@@ -5,7 +5,7 @@ # Each configuration option enables a list of files. obj-$(CONFIG_INPUT) += input-core.o -input-core-objs := input.o ff-core.o +input-core-objs := input.o input_compat.o ff-core.o obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
drivers/input/evdev.c +7 -111
160 lines not on this page · raw message
drivers/input/input_compat.c new file +89 -0
89 lines not on this page · raw message
drivers/input/misc/uinput.c +17 -6
@@ -37,6 +37,7 @@#include <linux/fs.h> #include <linux/miscdevice.h> #include <linux/uinput.h> +#include <linux/input_compat.h> static int uinput_dev_event (struct input_dev *dev,unsigned int type,unsigned int code,int value) {
@@ -351,15 +352,15 @@ static inline ssize_t uinput_inject_event(struct uinput_device *udev, const char {struct input_event ev; -if (count !=sizeof (struct input_event )) +if (count <input_event_size ())return -EINVAL ; -if (copy_from_user (&ev, buffer,sizeof (struct input_event ))) +if (input_event_from_user (buffer, &ev))return -EFAULT ;input_event (udev->dev, ev.type, ev.code, ev.value); -return sizeof (struct input_event ); +return input_event_size (); }static ssize_t uinput_write (struct file *file,const char __user *buffer,size_t count,loff_t *ppos)
@@ -405,13 +406,13 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count, goto out; } -while (udev->head != udev->tail && retval +sizeof (struct input_event ) <= count) { -if (copy_to_user (buffer + retval, &udev->buff[udev->tail],sizeof (struct input_event ))) { +while (udev->head != udev->tail && retval +input_event_size () <= count) { +if (input_event_to_user (buffer + retval, &udev->buff[udev->tail])) { retval = -EFAULT ; goto out; } udev->tail = (udev->tail +1 ) %UINPUT_BUFFER_SIZE ; - retval +=sizeof (struct input_event ); + retval +=input_event_size (); } out:
@@ -624,6 +625,13 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)return retval; } +#ifdef CONFIG_COMPAT +static long uinput_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +{ +return uinput_ioctl (file, cmd,compat_ptr (arg)); +} +#endif +static const struct file_operations uinput_fops = { .owner =THIS_MODULE , .open = uinput_open,
@@ -632,6 +640,9 @@ static const struct file_operations uinput_fops = { .write = uinput_write, .poll = uinput_poll, .unlocked_ioctl = uinput_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = uinput_compat_ioctl, +#endif };static struct miscdevice uinput_misc = {
include/linux/input_compat.h new file +61 -0
61 lines not on this page · raw message
Dmitry Torokhov
maintainerHi Philip,
Quoted 4 lines · Philip Langdale
Currently, evdev has working 32bit compatibility and uinput does not. uinput needs the
input_eventcode that evdev uses, so let's refactor it so it can be shared.
Looks very good, thank you. I just think that we should keep input_compat.h in drivers/input instead of include/linux and never show to anyone ;). I will change it on my side.
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerHi Philip,
Quoted 4 lines · Philip Langdale
Currently, evdev has working 32bit compatibility and uinput does not. uinput needs the
input_eventcode that evdev uses, so let's refactor it so it can be shared.
It was a pleasure talking to you yesterday. As I promised, here is the revision of your patch that I would like to commit to the next branch and I would appreciate if you could give it a try. The changes from the version you sent to me include hiding all uglies in drivers/input and also adding compat handling for the force feedback effects.
Sorry for sitting on it for so long.
Signature · 23 lines
Dmitry Input: refactor evdev 32bit compat to be shareable with uinput From: Philip Langdale <[email protected]> Currently, evdev has working 32bit compatibility and uinput does not. uinput needs the input_event code that evdev uses, so let's refactor it so it can be shared. [[email protected]: add fix for force feedback compat issues] Signed-off-by: Philip Langdale <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/Makefile | 2 drivers/input/evdev.c | 197 ++---------------------------------------- drivers/input/input-compat.c | 135 +++++++++++++++++++++++++++++ drivers/input/input-compat.h | 94 ++++++++++++++++++++ drivers/input/misc/uinput.c | 172 +++++++++++++++++++++++++++++++------ 5 files changed, 383 insertions(+), 217 deletions(-) create mode 100644 drivers/input/input-compat.c create mode 100644 drivers/input/input-compat.h
drivers/input/Makefile +1 -1
@@ -5,7 +5,7 @@ # Each configuration option enables a list of files. obj-$(CONFIG_INPUT) += input-core.o -input-core-objs := input.o ff-core.o +input-core-objs := input.o input-compat.o ff-core.o obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
drivers/input/evdev.c +8 -189
243 lines not on this page · raw message
drivers/input/input-compat.c new file +135 -0
135 lines not on this page · raw message
drivers/input/input-compat.h new file +94 -0
94 lines not on this page · raw message
drivers/input/misc/uinput.c +145 -27
294 lines not on this page · raw message
Dmitry Torokhov
maintainerQuoted 3 lines · Dmitry Torokhov
As I promised, here is the
revision of your patch that I would like to commit to the next branch and I would appreciate if you could give it a try.
Argh, not sure where what I sent came from but this one should at least compile...
Signature · 23 lines
Dmitry Input: refactor evdev 32bit compat to be shareable with uinput From: Philip Langdale <[email protected]> Currently, evdev has working 32bit compatibility and uinput does not. uinput needs the input_event code that evdev uses, so let's refactor it so it can be shared. [[email protected]: add fix for force feedback compat issues] Signed-off-by: Philip Langdale <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/Makefile | 2 drivers/input/evdev.c | 197 ++---------------------------------------- drivers/input/input-compat.c | 135 +++++++++++++++++++++++++++++ drivers/input/input-compat.h | 94 ++++++++++++++++++++ drivers/input/misc/uinput.c | 172 +++++++++++++++++++++++++++++++------ 5 files changed, 383 insertions(+), 217 deletions(-) create mode 100644 drivers/input/input-compat.c create mode 100644 drivers/input/input-compat.h
drivers/input/Makefile +1 -1
@@ -5,7 +5,7 @@ # Each configuration option enables a list of files. obj-$(CONFIG_INPUT) += input-core.o -input-core-objs := input.o ff-core.o +input-core-objs := input.o input-compat.o ff-core.o obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
drivers/input/evdev.c +8 -189
243 lines not on this page · raw message
drivers/input/input-compat.c new file +135 -0
135 lines not on this page · raw message
drivers/input/input-compat.h new file +94 -0
94 lines not on this page · raw message
drivers/input/misc/uinput.c +145 -27
294 lines not on this page · raw message
Quoted 8 lines · Dmitry Torokhov
Quoted 3 lines · Dmitry Torokhov
As I promised, here is the
revision of your patch that I would like to commit to the next branch and I would appreciate if you could give it a try.Argh, not sure where what I sent came from but this one should at least compile...
Compiles and works as advertised. Thanks!
--phil