[Click] [PATCH v2 5/5] ToUserDevice: use unlocked_ioctl if it's available

Eddie Kohler kohler at cs.ucla.edu
Tue Feb 1 14:36:25 EST 2011


On 02/01/2011 09:23 AM, Joonwoo Park wrote:
> Sure.  Will do.
> I was stick with submitting patches on the list rather than doing pull
> request with github as pull request is not sent out to mailing list
> meaning that may lose advantage patchset can get reviewed/tested by
> non collaborators/watchers.
> I'll do with compromised way like do pull request and send message on list.

An absolutely perfect combination in my opinion :)

E

>
> Thanks!
> Joonwoo
>
> On Tue, Feb 1, 2011 at 7:08 AM, Eddie Kohler<kohler at cs.ucla.edu>  wrote:
>> Joonwoo,
>>
>> Please send a revised entire series of patches, or better, use github to
>> prepare a pull request
>>
>> Thanks
>> E
>>
>>
>> On 1/31/11 11:20 PM, Joonwoo Park wrote:
>>>
>>> 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
>>


More information about the click mailing list