fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / watchdog / wdt.c
index 9ab9ff2..517fbd8 100644 (file)
@@ -31,7 +31,6 @@
  *             Matt Domsch     :       Added nowayout module option
  */
 
-#include <linux/config.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -63,12 +62,7 @@ static int wd_heartbeat;
 module_param(heartbeat, int, 0);
 MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(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)");
 
@@ -231,14 +225,13 @@ static int wdt_get_temperature(int *temperature)
  *     wdt_interrupt:
  *     @irq:           Interrupt number
  *     @dev_id:        Unused as we don't allow multiple devices.
- *     @regs:          Unused.
  *
  *     Handle an interrupt from the board. These are raised when the status
  *     map changes in what the board considers an interesting way. That means
  *     a failure condition occurring.
  */
 
-static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wdt_interrupt(int irq, void *dev_id)
 {
        /*
         *      Read the status register see what is up and
@@ -266,7 +259,7 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                printk(KERN_CRIT "Would Reboot.\n");
 #else
                printk(KERN_CRIT "Initiating system reboot.\n");
-               machine_restart(NULL);
+               emergency_restart();
 #endif
 #else
                printk(KERN_CRIT "Reset in 5ms.\n");
@@ -286,12 +279,8 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  *     write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+static ssize_t wdt_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;
@@ -327,6 +316,8 @@ static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_
 static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        unsigned long arg)
 {
+       void __user *argp = (void __user *)arg;
+       int __user *p = argp;
        int new_heartbeat;
        int status;
 
@@ -349,20 +340,20 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        switch(cmd)
        {
                default:
-                       return -ENOIOCTLCMD;
+                       return -ENOTTY;
                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:
                        wdt_get_status(&status);
-                       return put_user(status,(int *)arg);
+                       return put_user(status, p);
                case WDIOC_GETBOOTSTATUS:
-                       return put_user(0, (int *)arg);
+                       return put_user(0, p);
                case WDIOC_KEEPALIVE:
                        wdt_ping();
                        return 0;
                case WDIOC_SETTIMEOUT:
-                       if (get_user(new_heartbeat, (int *)arg))
+                       if (get_user(new_heartbeat, p))
                                return -EFAULT;
 
                        if (wdt_set_heartbeat(new_heartbeat))
@@ -371,7 +362,7 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                        wdt_ping();
                        /* Fall */
                case WDIOC_GETTIMEOUT:
-                       return put_user(heartbeat, (int *)arg);
+                       return put_user(heartbeat, p);
        }
 }
 
@@ -395,7 +386,7 @@ static int wdt_open(struct inode *inode, struct file *file)
         *      Activate
         */
        wdt_start();
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 /**
@@ -435,14 +426,10 @@ static int wdt_release(struct inode *inode, struct file *file)
  *     farenheit. It was designed by an imperial measurement luddite.
  */
 
-static ssize_t wdt_temp_read(struct file *file, char *buf, size_t count, loff_t *ptr)
+static ssize_t wdt_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
 {
        int temperature;
 
-       /*  Can't seek (pread) on this device  */
-       if (ptr != &file->f_pos)
-               return -ESPIPE;
-
        if (wdt_get_temperature(&temperature))
                return -EFAULT;
 
@@ -462,7 +449,7 @@ static ssize_t wdt_temp_read(struct file *file, char *buf, size_t count, loff_t
 
 static int wdt_temp_open(struct inode *inode, struct file *file)
 {
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 /**
@@ -506,7 +493,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
  */
 
 
-static struct file_operations wdt_fops = {
+static const struct file_operations wdt_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .write          = wdt_write,
@@ -522,7 +509,7 @@ static struct miscdevice wdt_miscdev = {
 };
 
 #ifdef CONFIG_WDT_501
-static struct file_operations wdt_temp_fops = {
+static const struct file_operations wdt_temp_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = wdt_temp_read,
@@ -592,7 +579,7 @@ static int __init wdt_init(void)
                goto out;
        }
 
-       ret = request_irq(irq, wdt_interrupt, SA_INTERRUPT, "wdt501p", NULL);
+       ret = request_irq(irq, wdt_interrupt, IRQF_DISABLED, "wdt501p", NULL);
        if(ret) {
                printk(KERN_ERR "wdt: IRQ %d is not free.\n", irq);
                goto outreg;
@@ -633,8 +620,8 @@ out:
 outmisc:
 #ifdef CONFIG_WDT_501
        misc_deregister(&temp_miscdev);
-#endif /* CONFIG_WDT_501 */
 outrbt:
+#endif /* CONFIG_WDT_501 */
        unregister_reboot_notifier(&wdt_notifier);
 outirq:
        free_irq(irq, NULL);