fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / watchdog / advantechwdt.c
index a92b3ae..9d73276 100644 (file)
@@ -73,12 +73,7 @@ static int timeout = WATCHDOG_TIMEOUT;       /* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=63, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
-#ifdef CONFIG_WATCHDOG_NOWAYOUT
-static int nowayout = 1;
-#else
-static int nowayout = 0;
-#endif
-
+static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
 
@@ -100,12 +95,8 @@ advwdt_disable(void)
 }
 
 static ssize_t
-advwdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+advwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       /*  Can't seek (pwrite) on this device  */
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-
        if (count) {
                if (!nowayout) {
                        size_t i;
@@ -130,6 +121,8 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
          unsigned long arg)
 {
        int new_timeout;
+       void __user *argp = (void __user *)arg;
+       int __user *p = argp;
        static struct watchdog_info ident = {
                .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
                .firmware_version = 1,
@@ -138,20 +131,20 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
        switch (cmd) {
        case WDIOC_GETSUPPORT:
-         if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
+         if (copy_to_user(argp, &ident, sizeof(ident)))
            return -EFAULT;
          break;
 
        case WDIOC_GETSTATUS:
        case WDIOC_GETBOOTSTATUS:
-         return put_user(0, (int *)arg);
+         return put_user(0, p);
 
        case WDIOC_KEEPALIVE:
          advwdt_ping();
          break;
 
        case WDIOC_SETTIMEOUT:
-         if (get_user(new_timeout, (int *)arg))
+         if (get_user(new_timeout, p))
                  return -EFAULT;
          if ((new_timeout < 1) || (new_timeout > 63))
                  return -EINVAL;
@@ -160,13 +153,13 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
          /* Fall */
 
        case WDIOC_GETTIMEOUT:
-         return put_user(timeout, (int *)arg);
+         return put_user(timeout, p);
 
        case WDIOC_SETOPTIONS:
        {
          int options, retval = -EINVAL;
 
-         if (get_user(options, (int *)arg))
+         if (get_user(options, p))
            return -EFAULT;
 
          if (options & WDIOS_DISABLECARD) {
@@ -183,7 +176,7 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        }
 
        default:
-         return -ENOIOCTLCMD;
+         return -ENOTTY;
        }
        return 0;
 }
@@ -198,7 +191,7 @@ advwdt_open(struct inode *inode, struct file *file)
         */
 
        advwdt_ping();
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int
@@ -234,7 +227,7 @@ advwdt_notify_sys(struct notifier_block *this, unsigned long code,
  *     Kernel Interfaces
  */
 
-static struct file_operations advwdt_fops = {
+static const struct file_operations advwdt_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .write          = advwdt_write,