diff mbox

[v2,07/29] usb: usbtmc: Add support for 32 bit compat applications

Message ID 20180718084602.10568-8-guido@kiener-muenchen.de (mailing list archive)
State New, archived
Headers show

Commit Message

Guido Kiener July 18, 2018, 8:45 a.m. UTC
32 bit applications can only call ioctl functions on 64 bit systems
when the field .compat_ioctl is defined for file operations.

Tested-by: Dave Penkler <dpenkler@gmail.com>
Signed-off-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
Reviewed-by: Steve Bayless <steve_bayless@keysight.com>
---
 drivers/usb/class/usbtmc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox

Patch

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 1b7b2e402adb..d685db78b80b 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -18,6 +18,7 @@ 
 #include <linux/poll.h>
 #include <linux/mutex.h>
 #include <linux/usb.h>
+#include <linux/compat.h>
 #include <linux/usb/tmc.h>
 
 
@@ -1423,6 +1424,14 @@  static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return retval;
 }
 
+#ifdef CONFIG_COMPAT
+static long usbtmc_compat_ioctl(struct file *file, unsigned int cmd,
+				unsigned long arg)
+{
+	return usbtmc_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static int usbtmc_fasync(int fd, struct file *file, int on)
 {
 	struct usbtmc_file_data *file_data = file->private_data;
@@ -1459,6 +1468,9 @@  static const struct file_operations fops = {
 	.open		= usbtmc_open,
 	.release	= usbtmc_release,
 	.unlocked_ioctl	= usbtmc_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= usbtmc_compat_ioctl,
+#endif
 	.fasync         = usbtmc_fasync,
 	.poll           = usbtmc_poll,
 	.llseek		= default_llseek,