Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / char / watchdog / wdt_pci.c
index 395df48..5918ca2 100644 (file)
@@ -35,7 +35,6 @@
  *             Matt Domsch     :       nowayout module option
  */
 
-#include <linux/config.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -89,12 +88,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)");
 
@@ -311,7 +305,7 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                printk(KERN_CRIT PFX "Would Reboot.\n");
 #else
                printk(KERN_CRIT PFX "Initiating system reboot.\n");
-               machine_restart(NULL);
+               emergency_restart(NULL);
 #endif
 #else
                printk(KERN_CRIT PFX "Reset in 5ms.\n");
@@ -331,12 +325,8 @@ static irqreturn_t wdtpci_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 wdtpci_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+static ssize_t wdtpci_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;
@@ -374,6 +364,8 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd
 {
        int new_heartbeat;
        int status;
+       void __user *argp = (void __user *)arg;
+       int __user *p = argp;
 
        static struct watchdog_info ident = {
                .options =              WDIOF_SETTIMEOUT|
@@ -396,18 +388,18 @@ static int wdtpci_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:
                        wdtpci_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:
                        wdtpci_ping();
                        return 0;
                case WDIOC_SETTIMEOUT:
-                       if (get_user(new_heartbeat, (int *)arg))
+                       if (get_user(new_heartbeat, p))
                                return -EFAULT;
 
                        if (wdtpci_set_heartbeat(new_heartbeat))
@@ -416,7 +408,7 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                        wdtpci_ping();
                        /* Fall */
                case WDIOC_GETTIMEOUT:
-                       return put_user(heartbeat, (int *)arg);
+                       return put_user(heartbeat, p);
        }
 }
 
@@ -444,7 +436,7 @@ static int wdtpci_open(struct inode *inode, struct file *file)
         *      Activate
         */
        wdtpci_start();
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 /**
@@ -484,14 +476,10 @@ static int wdtpci_release(struct inode *inode, struct file *file)
  *     fahrenheit. It was designed by an imperial measurement luddite.
  */
 
-static ssize_t wdtpci_temp_read(struct file *file, char *buf, size_t count, loff_t *ptr)
+static ssize_t wdtpci_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 (wdtpci_get_temperature(&temperature))
                return -EFAULT;
 
@@ -511,7 +499,7 @@ static ssize_t wdtpci_temp_read(struct file *file, char *buf, size_t count, loff
 
 static int wdtpci_temp_open(struct inode *inode, struct file *file)
 {
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 /**
@@ -555,7 +543,7 @@ static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
  */
 
 
-static struct file_operations wdtpci_fops = {
+static const struct file_operations wdtpci_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .write          = wdtpci_write,
@@ -571,7 +559,7 @@ static struct miscdevice wdtpci_miscdev = {
 };
 
 #ifdef CONFIG_WDT_501_PCI
-static struct file_operations wdtpci_temp_fops = {
+static const struct file_operations wdtpci_temp_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = wdtpci_temp_read,
@@ -629,7 +617,7 @@ static int __devinit wdtpci_init_one (struct pci_dev *dev,
                goto out_pci;
        }
 
-       if (request_irq (irq, wdtpci_interrupt, SA_INTERRUPT | SA_SHIRQ,
+       if (request_irq (irq, wdtpci_interrupt, IRQF_DISABLED | IRQF_SHARED,
                         "wdt_pci", &wdtpci_miscdev)) {
                printk (KERN_ERR PFX "IRQ %d is not free\n", irq);
                goto out_reg;
@@ -680,8 +668,8 @@ out:
 out_misc:
 #ifdef CONFIG_WDT_501_PCI
        misc_deregister(&temp_miscdev);
-#endif /* CONFIG_WDT_501_PCI */
 out_rbt:
+#endif /* CONFIG_WDT_501_PCI */
        unregister_reboot_notifier(&wdtpci_notifier);
 out_irq:
        free_irq(irq, &wdtpci_miscdev);