[Click] [PATCH v2 5/5] ToUserDevice: use unlocked_ioctl if it's available
Joonwoo Park
joonwpark81 at gmail.com
Tue Feb 1 02:20:10 EST 2011
Hi Eddie,
Please find revised version of patch. This includes additional mutex as well as argument fix from previous patch.
Thanks,
Joonwoo
---
elements/linuxmodule/touserdevice.cc | 20 ++++++++++++++++++++
elements/linuxmodule/touserdevice.hh | 7 +++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/elements/linuxmodule/touserdevice.cc b/elements/linuxmodule/touserdevice.cc
index fc0dc41..5285790 100644
--- a/elements/linuxmodule/touserdevice.cc
+++ b/elements/linuxmodule/touserdevice.cc
@@ -52,6 +52,7 @@ static int DEV_MINOR = 0;
static int DEV_NUM = 0;
struct file_operations *ToUserDevice::dev_fops;
+static struct mutex ToUserDevice::_ioctl_mutex;
static volatile ToUserDevice *elem[20] = {0};
@@ -91,8 +92,16 @@ void ToUserDevice::static_initialize()
dev_fops->poll = dev_poll;
dev_fops->open = dev_open;
dev_fops->release = dev_release;
+#if HAVE_UNLOCKED_IOCTL
+ dev_fops->unlocked_ioctl = dev_unlocked_ioctl;
+#else
dev_fops->ioctl = dev_ioctl;
+#endif
}
+
+#if HAVE_UNLOCKED_IOCTL
+ mutex_init(&_ioctl_mutex);
+#endif
}
void ToUserDevice::static_cleanup()
@@ -128,6 +137,17 @@ int ToUserDevice::dev_release(struct inode *inode, struct file *filp)
return 0;
}
+#if HAVE_UNLOCKED_IOCTL
+long ToUserDevice::dev_unlocked_ioctl(struct file *filp, unsigned int command,
+ unsigned long address)
+{
+ mutex_lock(&_ioctl_mutex);
+ long ret = dev_ioctl(NULL, filp, command, address);
+ mutex_unlock(&_ioctl_mutex);
+ return ret;
+}
+#endif
+
int ToUserDevice::dev_ioctl(struct inode *inode, struct file *filp,
unsigned command, unsigned long address)
{
diff --git a/elements/linuxmodule/touserdevice.hh b/elements/linuxmodule/touserdevice.hh
index b697ec8..80f3baa 100644
--- a/elements/linuxmodule/touserdevice.hh
+++ b/elements/linuxmodule/touserdevice.hh
@@ -131,6 +131,9 @@ private:
ulong _sleep_proc;
static struct file_operations *dev_fops;
+#if HAVE_UNLOCKED_IOCTL
+ static struct mutex _ioctl_mutex;
+#endif
static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *ppos);
static int dev_open(struct inode *inode, struct file *filp);
@@ -138,6 +141,10 @@ private:
static uint dev_poll(struct file *, struct poll_table_struct *);
static int dev_ioctl(struct inode *inode, struct file *filp,
unsigned command, unsigned long address);
+#if HAVE_UNLOCKED_IOCTL
+ static long dev_unlocked_ioctl(struct file *filp, unsigned int command,
+ unsigned long address);
+#endif
};
#endif
--
1.7.1
On Sun, Jan 30, 2011 at 01:23:34AM -0800, Joonwoo Park wrote:
> Signed-off-by: Joonwoo Park <joonwpark81 at gmail.com>
> ---
> elements/linuxmodule/touserdevice.cc | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/elements/linuxmodule/touserdevice.cc b/elements/linuxmodule/touserdevice.cc
> index fc0dc41..b3fa85b 100644
> --- a/elements/linuxmodule/touserdevice.cc
> +++ b/elements/linuxmodule/touserdevice.cc
> @@ -91,7 +91,11 @@ void ToUserDevice::static_initialize()
> dev_fops->poll = dev_poll;
> dev_fops->open = dev_open;
> dev_fops->release = dev_release;
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
> + dev_fops->unlocked_ioctl = dev_ioctl;
> +#else
> dev_fops->ioctl = dev_ioctl;
> +#endif
> }
> }
>
> --
> 1.7.1
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-ToUserDevice-use-unlocked_ioctl-if-it-s-available.patch
Type: text/x-diff
Size: 2706 bytes
Desc: not available
Url : http://amsterdam.lcs.mit.edu/pipermail/click/attachments/20110131/f2126f08/attachment.patch
More information about the click
mailing list