changeset 119:7662d0ecd74b

revised new ioctl functions
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 19 Nov 2010 11:19:25 +0900
parents 53266592882d
children 3914cc1b2375
files driver/pt1_pci.c
diffstat 1 files changed, 34 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/driver/pt1_pci.c	Thu Nov 18 23:01:40 2010 +0900
+++ b/driver/pt1_pci.c	Fri Nov 19 11:19:25 2010 +0900
@@ -33,6 +33,7 @@
 #include <linux/cdev.h>
 
 #include <linux/ioctl.h>
+#include <linux/smp_lock.h>
 
 #include	"pt1_com.h"
 #include	"pt1_pci.h"
@@ -511,11 +512,7 @@
 	return count;
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
-static	long	pt1_ioctl(struct file  *file, unsigned int cmd, unsigned long arg0)
-#else
-static	int	pt1_ioctl(struct inode *inode, struct file  *file, unsigned int cmd, unsigned long arg0)
-#endif
+static long pt1_do_ioctl(struct file  *file, unsigned int cmd, unsigned long arg0)
 {
 	PT1_CHANNEL	*channel = file->private_data;
 	int		signal;
@@ -572,6 +569,35 @@
 	return -EINVAL;
 }
 
+static long pt1_unlocked_ioctl(struct file  *file, unsigned int cmd, unsigned long arg0)
+{
+	long ret;
+
+	lock_kernel();
+	ret = pt1_do_ioctl(file, cmd, arg0);
+	unlock_kernel();
+
+	return ret;
+}
+
+static long pt1_compat_ioctl(struct file  *file, unsigned int cmd, unsigned long arg0)
+{
+	long ret;
+	/* should do 32bit <-> 64bit conversion here? --yaz */
+	ret = pt1_unlocked_ioctl(file, cmd, arg0);
+
+	return ret;
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
+static int pt1_ioctl(struct inode *inode, struct file  *file, unsigned int cmd, unsigned long arg0)
+{
+	int ret;
+	ret = (int)pt1_do_ioctl(file, cmd, arg0);
+	return ret;
+}
+#endif
+
 /*
 */
 static const struct file_operations pt1_fops = {
@@ -579,11 +605,11 @@
 	.open		=	pt1_open,
 	.release	=	pt1_release,
 	.read		=	pt1_read,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
-	.unlocked_ioctl		=	pt1_ioctl,
-#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
 	.ioctl		=	pt1_ioctl,
 #endif
+	.unlocked_ioctl		=	pt1_unlocked_ioctl,
+	.compat_ioctl		=	pt1_compat_ioctl,
 	.llseek		=	no_llseek,
 };