Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / watchdog / sc520_wdt.c
index b54c47b..4ee9974 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
+#include <linux/jiffies.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -94,12 +95,7 @@ static int timeout = WATCHDOG_TIMEOUT;       /* in seconds, will be multiplied by HZ t
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, 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)");
 
@@ -122,7 +118,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON
 #define WDT_WRST_ENB   0x4000  /* [14] Watchdog Timer Reset Enable */
 #define WDT_ENB                0x8000  /* [15] Watchdog Timer Enable */
 
-static __u16 *wdtmrctl;
+static __u16 __iomem *wdtmrctl;
 
 static void wdt_timer_ping(unsigned long);
 static struct timer_list timer;
@@ -225,12 +221,8 @@ static int wdt_set_heartbeat(int t)
  *     /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file * file, const char * buf, size_t count, loff_t * ppos)
+static ssize_t fop_write(struct file * file, const char __user * buf, size_t count, loff_t * ppos)
 {
-       /* We can't seek */
-       if(ppos != &file->f_pos)
-               return -ESPIPE;
-
        /* See if we got the magic character 'V' and reload the timer */
        if(count) {
                if (!nowayout) {
@@ -258,6 +250,8 @@ static ssize_t fop_write(struct file * file, const char * buf, size_t count, lof
 
 static int fop_open(struct inode * inode, struct file * file)
 {
+       nonseekable_open(inode, file);
+
        /* Just in case we're already talking to someone... */
        if(test_and_set_bit(0, &wdt_is_open))
                return -EBUSY;
@@ -285,6 +279,8 @@ static int fop_close(struct inode * inode, struct file * file)
 static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        unsigned long arg)
 {
+       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,
@@ -296,10 +292,10 @@ static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                default:
                        return -ENOIOCTLCMD;
                case WDIOC_GETSUPPORT:
-                       return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0;
+                       return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0;
                case WDIOC_GETSTATUS:
                case WDIOC_GETBOOTSTATUS:
-                       return put_user(0, (int *)arg);
+                       return put_user(0, p);
                case WDIOC_KEEPALIVE:
                        wdt_keepalive();
                        return 0;
@@ -307,7 +303,7 @@ static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                {
                        int new_options, retval = -EINVAL;
 
-                       if(get_user(new_options, (int *)arg))
+                       if(get_user(new_options, p))
                                return -EFAULT;
 
                        if(new_options & WDIOS_DISABLECARD) {
@@ -326,7 +322,7 @@ static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                {
                        int new_timeout;
 
-                       if(get_user(new_timeout, (int *)arg))
+                       if(get_user(new_timeout, p))
                                return -EFAULT;
 
                        if(wdt_set_heartbeat(new_timeout))
@@ -336,7 +332,7 @@ static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                        /* Fall through */
                }
                case WDIOC_GETTIMEOUT:
-                       return put_user(timeout, (int *)arg);
+                       return put_user(timeout, p);
        }
 }