[PATCH] hiddev: Add 32bit ioctl compatibilty

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jiri Kosina <jkosina@...>
Cc: LKML <linux-kernel@...>
Date: Friday, October 12, 2007 - 7:51 pm

The hiddev driver currently lacks 32bit ioctl compatibility, so
if you're running with a 64bit kernel and 32bit userspace, it won't
work.

I'm pretty sure that the only thing missing is a compat_ioctl
implementation as all structs have fixed size fields.

With this change I can use revoco to configure my MX Revolution mouse.

Signed-off-by: Philip Langdale <philipl@overt.org>

--- linux-2.6.23/drivers/hid/usbhid/hiddev.c	2007-10-09 13:31:38.000000000 -0700
+++ linux-phil/drivers/hid/usbhid/hiddev.c	2007-10-12 15:02:15.000000000 -0700
@@ -34,6 +34,7 @@
 #include <linux/usb.h>
 #include <linux/hid.h>
 #include <linux/hiddev.h>
+#include <linux/compat.h>
 #include "usbhid.h"

 #ifdef CONFIG_USB_DYNAMIC_MINORS
@@ -738,6 +738,14 @@
 	return -EINVAL;
 }

+#ifdef CONFIG_COMPAT
+static long hiddev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct inode *inode = file->f_path.dentry->d_inode;
+	return hiddev_ioctl(inode, file, cmd, compat_ptr(arg));
+}
+#endif
+
 static const struct file_operations hiddev_fops = {
 	.owner =	THIS_MODULE,
 	.read =		hiddev_read,
@@ -747,6 +754,9 @@
 	.release =	hiddev_release,
 	.ioctl =	hiddev_ioctl,
 	.fasync =	hiddev_fasync,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= hiddev_compat_ioctl,
+#endif
 };

 static struct usb_class_driver hiddev_class = {
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] hiddev: Add 32bit ioctl compatibilty, Philip Langdale, (Fri Oct 12, 7:51 pm)
Re: [PATCH] hiddev: Add 32bit ioctl compatibilty, Al Viro, (Fri Oct 12, 8:02 pm)
Re: [PATCH] compat_ioctl: introduce generic_compat_ioctl hel..., Christoph Hellwig, (Sat Oct 20, 12:11 pm)
[PATCH] hiddev: simplify 32bit ioctl compatibilty, Arnd Bergmann, (Sat Oct 20, 12:03 pm)
Re: [PATCH] hiddev: Add 32bit ioctl compatibilty, Philip Langdale, (Sat Oct 13, 1:42 pm)