This is drivers/input/evdev.c fixed to use the new infrastructure and the existing compat bitmap copying routine. --- evdev.c | 54 ++++++++++++------------------------------------------ 1 files changed, 12 insertions(+), 42 deletions(-)
-- Cheers, Stephen Rothwell [EMAIL PROTECTED] http://www.canb.auug.org.au/~sfr/ diff -ruN linus-compat_write.4/drivers/input/evdev.c linus-compat_write.5/drivers/input/evdev.c --- linus-compat_write.4/drivers/input/evdev.c 2005-06-28 10:05:26.000000000 +1000 +++ linus-compat_write.5/drivers/input/evdev.c 2005-07-01 00:51:37.000000000 +1000 @@ -154,16 +154,6 @@ __s32 value; }; -#ifdef CONFIG_X86_64 -# define COMPAT_TEST test_thread_flag(TIF_IA32) -#elif defined(CONFIG_IA64) -# define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current)) -#elif defined(CONFIG_ARCH_S390) -# define COMPAT_TEST test_thread_flag(TIF_31BIT) -#else -# define COMPAT_TEST test_thread_flag(TIF_32BIT) -#endif - static ssize_t evdev_write_compat(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) { struct evdev_list *list = file->private_data; @@ -179,6 +169,8 @@ return retval; } +#else +#define evdev_write_compat NULL #endif static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) @@ -189,11 +181,6 @@ if (!list->evdev->exist) return -ENODEV; -#ifdef CONFIG_COMPAT - if (COMPAT_TEST) - return evdev_write_compat(file, buffer, count, ppos); -#endif - while (retval < count) { if (copy_from_user(&event, buffer + retval, sizeof(struct input_event))) @@ -243,6 +230,8 @@ return retval; } +#else +#define evdev_read_compat NULL #endif static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) @@ -250,11 +239,6 @@ struct evdev_list *list = file->private_data; int retval; -#ifdef CONFIG_COMPAT - if (COMPAT_TEST) - return evdev_read_compat(file, buffer, count, ppos); -#endif - if (count < sizeof(struct input_event)) return -EINVAL; @@ -484,34 +468,18 @@ #ifdef CONFIG_COMPAT -#define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8) -#define NBITS_COMPAT(x) ((((x)-1)/BITS_PER_LONG_COMPAT)+1) -#define OFF_COMPAT(x) ((x)%BITS_PER_LONG_COMPAT) +#define NBITS_COMPAT(x) ((((x)-1)/BITS_PER_COMPAT_LONG)+1) +#define OFF_COMPAT(x) ((x)%BITS_PER_COMPAT_LONG) #define BIT_COMPAT(x) (1UL<<OFF_COMPAT(x)) -#define LONG_COMPAT(x) ((x)/BITS_PER_LONG_COMPAT) +#define LONG_COMPAT(x) ((x)/BITS_PER_COMPAT_LONG) #define test_bit_compat(bit, array) ((array[LONG_COMPAT(bit)] >> OFF_COMPAT(bit)) & 1) -#ifdef __BIG_ENDIAN #define bit_to_user(bit, max) \ do { \ - int i; \ int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ - for (i = 0; i < len / sizeof(compat_long_t); i++) \ - if (copy_to_user((compat_long_t*) p + i, \ - (compat_long_t*) (bit) + i + 1 - ((i % 2) << 1), \ - sizeof(compat_long_t))) \ - return -EFAULT; \ - return len; \ + return compat_put_bitmap(p, (bit), len * 8) ? -EFAULT : len; \ } while (0) -#else -#define bit_to_user(bit, max) \ -do { \ - int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ - return copy_to_user(p, (bit), len) ? -EFAULT : len; \ -} while (0) -#endif static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { @@ -631,19 +599,21 @@ } return -EINVAL; } +#else +#define evdev_ioctl_compat NULL #endif static struct file_operations evdev_fops = { .owner = THIS_MODULE, .read = evdev_read, + .compat_read = evdev_read_compat, .write = evdev_write, + .compat_write = evdev_write_compat, .poll = evdev_poll, .open = evdev_open, .release = evdev_release, .unlocked_ioctl = evdev_ioctl, -#ifdef CONFIG_COMPAT .compat_ioctl = evdev_ioctl_compat, -#endif .fasync = evdev_fasync, .flush = evdev_flush };
pgpEMWegBmhVn.pgp
Description: PGP signature
