lkml.org 
[lkml]   [2009]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/13] [watchdog] changed ioctls to unlocked
Date
From: Stoyan Gaydarov <stoyboyker@gmail.com>

Signed-off-by: Stoyan Gaydarov <stoyboyker@gmail.com>
---
drivers/watchdog/riowd.c | 37 +++++++++++++++++++++++++++----------
1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c
index 09cb183..44058c1 100644
--- a/drivers/watchdog/riowd.c
+++ b/drivers/watchdog/riowd.c
@@ -86,9 +86,10 @@ static int riowd_release(struct inode *inode, struct file *filp)
return 0;
}

-static int riowd_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static long riowd_ioctl(struct file *filp, unsigned int cmd,
+ unsigned long arg)
{
+ lock_kernel();
static struct watchdog_info info = {
.options = WDIOF_SETTIMEOUT,
.firmware_version = 1,
@@ -101,14 +102,18 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,

switch (cmd) {
case WDIOC_GETSUPPORT:
- if (copy_to_user(argp, &info, sizeof(info)))
+ if (copy_to_user(argp, &info, sizeof(info))) {
+ unlock_kernel();
return -EFAULT;
+ }
break;

case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
- if (put_user(0, (int __user *)argp))
+ if (put_user(0, (int __user *)argp)) {
+ unlock_kernel();
return -EFAULT;
+ }
break;

case WDIOC_KEEPALIVE:
@@ -116,34 +121,46 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,
break;

case WDIOC_SETOPTIONS:
- if (copy_from_user(&options, argp, sizeof(options)))
+ if (copy_from_user(&options, argp, sizeof(options))) {
+ unlock_kernel();
return -EFAULT;
+ }

if (options & WDIOS_DISABLECARD)
riowd_writereg(p, 0, WDTO_INDEX);
else if (options & WDIOS_ENABLECARD)
riowd_writereg(p, riowd_timeout, WDTO_INDEX);
- else
+ else {
+ unlock_kernel();
return -EINVAL;
+ }

break;

case WDIOC_SETTIMEOUT:
- if (get_user(new_margin, (int __user *)argp))
+ if (get_user(new_margin, (int __user *)argp)) {
+ unlock_kernel();
return -EFAULT;
- if ((new_margin < 60) || (new_margin > (255 * 60)))
+ }
+ if ((new_margin < 60) || (new_margin > (255 * 60))) {
+ unlock_kernel();
return -EINVAL;
+ }
riowd_timeout = (new_margin + 59) / 60;
riowd_writereg(p, riowd_timeout, WDTO_INDEX);
/* Fall */

case WDIOC_GETTIMEOUT:
- return put_user(riowd_timeout * 60, (int __user *)argp);
+ long ret = put_user(riowd_timeout * 60, (int __user *)argp);
+ unlock_kernel();
+ return ret;

default:
+ unlock_kernel();
return -EINVAL;
};

+ unlock_kernel();
return 0;
}

@@ -162,7 +179,7 @@ static ssize_t riowd_write(struct file *file, const char __user *buf, size_t cou
static const struct file_operations riowd_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = riowd_ioctl,
+ .unlocked_ioctl = riowd_ioctl,
.open = riowd_open,
.write = riowd_write,
.release = riowd_release,
--
1.6.2


\
 
 \ /
  Last update: 2009-03-24 22:23    [W:0.062 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site