fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / watchdog / ib700wdt.c
index 14afe80..c1ed209 100644 (file)
@@ -31,7 +31,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/miscdevice.h>
@@ -117,12 +116,7 @@ static int wd_times[] = {
 
 static int wd_margin = WD_TIMO;
 
-#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)");
 
@@ -135,16 +129,12 @@ static void
 ibwdt_ping(void)
 {
        /* Write a watchdog value */
-       outb_p(wd_times[wd_margin], WDT_START);
+       outb_p(wd_margin, WDT_START);
 }
 
 static ssize_t
-ibwdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+ibwdt_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;
@@ -170,6 +160,8 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
          unsigned long arg)
 {
        int i, new_margin;
+       void __user *argp = (void __user *)arg;
+       int __user *p = argp;
 
        static struct watchdog_info ident = {
                .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
@@ -179,19 +171,19 @@ ibwdt_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:
-         return put_user(0, (int *) arg);
+         return put_user(0, p);
 
        case WDIOC_KEEPALIVE:
          ibwdt_ping();
          break;
 
        case WDIOC_SETTIMEOUT:
-         if (get_user(new_margin, (int *)arg))
+         if (get_user(new_margin, p))
                  return -EFAULT;
          if ((new_margin < 0) || (new_margin > 30))
                  return -EINVAL;
@@ -203,11 +195,11 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
          /* Fall */
 
        case WDIOC_GETTIMEOUT:
-         return put_user(wd_times[wd_margin], (int *)arg);
+         return put_user(wd_times[wd_margin], p);
          break;
 
        default:
-         return -ENOIOCTLCMD;
+         return -ENOTTY;
        }
        return 0;
 }
@@ -226,7 +218,7 @@ ibwdt_open(struct inode *inode, struct file *file)
        /* Activate */
        ibwdt_ping();
        spin_unlock(&ibwdt_lock);
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int
@@ -234,7 +226,7 @@ ibwdt_close(struct inode *inode, struct file *file)
 {
        spin_lock(&ibwdt_lock);
        if (expect_close == 42)
-               outb_p(wd_times[wd_margin], WDT_STOP);
+               outb_p(0, WDT_STOP);
        else
                printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
 
@@ -254,7 +246,7 @@ ibwdt_notify_sys(struct notifier_block *this, unsigned long code,
 {
        if (code == SYS_DOWN || code == SYS_HALT) {
                /* Turn the WDT off */
-               outb_p(wd_times[wd_margin], WDT_STOP);
+               outb_p(0, WDT_STOP);
        }
        return NOTIFY_DONE;
 }
@@ -263,8 +255,9 @@ ibwdt_notify_sys(struct notifier_block *this, unsigned long code,
  *     Kernel Interfaces
  */
 
-static struct file_operations ibwdt_fops = {
+static const struct file_operations ibwdt_fops = {
        .owner          = THIS_MODULE,
+       .llseek         = no_llseek,
        .write          = ibwdt_write,
        .ioctl          = ibwdt_ioctl,
        .open           = ibwdt_open,