fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / watchdog / scx200_wdt.c
index ed1800c..fc0e034 100644 (file)
@@ -4,7 +4,7 @@
 
    Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
 
-   Som code taken from:
+   Some code taken from:
    National Semiconductor PC87307/PC97307 (ala SC1200) WDT driver
    (c) Copyright 2002 Zwane Mwaikambo <zwane@commfireservices.com>
 
@@ -17,7 +17,6 @@
    of any nature resulting due to the use of this software. This
    software is provided AS-IS with no warranties. */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -39,15 +38,11 @@ MODULE_DESCRIPTION("NatSemi SCx200 Watchdog Driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
 
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
-#define CONFIG_WATCHDOG_NOWAYOUT 0
-#endif
-
 static int margin = 60;                /* in seconds */
 module_param(margin, int, 0);
 MODULE_PARM_DESC(margin, "Watchdog margin in seconds");
 
-static int nowayout = CONFIG_WATCHDOG_NOWAYOUT;
+static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
 
@@ -64,7 +59,7 @@ static char expect_close;
 
 static void scx200_wdt_ping(void)
 {
-       outw(wdto_restart, SCx200_CB_BASE + SCx200_WDT_WDTO);
+       outw(wdto_restart, scx200_cb_base + SCx200_WDT_WDTO);
 }
 
 static void scx200_wdt_update_margin(void)
@@ -78,9 +73,9 @@ static void scx200_wdt_enable(void)
        printk(KERN_DEBUG NAME ": enabling watchdog timer, wdto_restart = %d\n",
               wdto_restart);
 
-       outw(0, SCx200_CB_BASE + SCx200_WDT_WDTO);
-       outb(SCx200_WDT_WDSTS_WDOVF, SCx200_CB_BASE + SCx200_WDT_WDSTS);
-       outw(W_ENABLE, SCx200_CB_BASE + SCx200_WDT_WDCNFG);
+       outw(0, scx200_cb_base + SCx200_WDT_WDTO);
+       outb(SCx200_WDT_WDSTS_WDOVF, scx200_cb_base + SCx200_WDT_WDSTS);
+       outw(W_ENABLE, scx200_cb_base + SCx200_WDT_WDCNFG);
 
        scx200_wdt_ping();
 }
@@ -89,9 +84,9 @@ static void scx200_wdt_disable(void)
 {
        printk(KERN_DEBUG NAME ": disabling watchdog timer\n");
 
-       outw(0, SCx200_CB_BASE + SCx200_WDT_WDTO);
-       outb(SCx200_WDT_WDSTS_WDOVF, SCx200_CB_BASE + SCx200_WDT_WDSTS);
-       outw(W_DISABLE, SCx200_CB_BASE + SCx200_WDT_WDCNFG);
+       outw(0, scx200_cb_base + SCx200_WDT_WDTO);
+       outb(SCx200_WDT_WDSTS_WDOVF, scx200_cb_base + SCx200_WDT_WDSTS);
+       outw(W_DISABLE, scx200_cb_base + SCx200_WDT_WDCNFG);
 }
 
 static int scx200_wdt_open(struct inode *inode, struct file *file)
@@ -171,7 +166,7 @@ static int scx200_wdt_ioctl(struct inode *inode, struct file *file,
 
        switch (cmd) {
        default:
-               return -ENOIOCTLCMD;
+               return -ENOTTY;
        case WDIOC_GETSUPPORT:
                if(copy_to_user(argp, &ident, sizeof(ident)))
                        return -EFAULT;
@@ -199,8 +194,9 @@ static int scx200_wdt_ioctl(struct inode *inode, struct file *file,
        }
 }
 
-static struct file_operations scx200_wdt_fops = {
+static const struct file_operations scx200_wdt_fops = {
        .owner   = THIS_MODULE,
+       .llseek  = no_llseek,
        .write   = scx200_wdt_write,
        .ioctl   = scx200_wdt_ioctl,
        .open    = scx200_wdt_open,
@@ -209,7 +205,7 @@ static struct file_operations scx200_wdt_fops = {
 
 static struct miscdevice scx200_wdt_miscdev = {
        .minor = WATCHDOG_MINOR,
-       .name  = NAME,
+       .name  = "watchdog",
        .fops  = &scx200_wdt_fops,
 };
 
@@ -219,25 +215,11 @@ static int __init scx200_wdt_init(void)
 
        printk(KERN_DEBUG NAME ": NatSemi SCx200 Watchdog Driver\n");
 
-       /*
-        * First check that this really is a NatSemi SCx200 CPU or a Geode
-        * SC1100 processor
-        */
-       if ((pci_find_device(PCI_VENDOR_ID_NS,
-                            PCI_DEVICE_ID_NS_SCx200_BRIDGE,
-                            NULL)) == NULL
-           && (pci_find_device(PCI_VENDOR_ID_NS,
-                               PCI_DEVICE_ID_NS_SC1100_BRIDGE,
-                               NULL)) == NULL)
-               return -ENODEV;
-
-       /* More sanity checks, verify that the configuration block is there */
-       if (!scx200_cb_probe(SCx200_CB_BASE)) {
-               printk(KERN_WARNING NAME ": no configuration block found\n");
+       /* check that we have found the configuration block */
+       if (!scx200_cb_present())
                return -ENODEV;
-       }
 
-       if (!request_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
+       if (!request_region(scx200_cb_base + SCx200_WDT_OFFSET,
                            SCx200_WDT_SIZE,
                            "NatSemi SCx200 Watchdog")) {
                printk(KERN_WARNING NAME ": watchdog I/O region busy\n");
@@ -251,7 +233,7 @@ static int __init scx200_wdt_init(void)
 
        r = misc_register(&scx200_wdt_miscdev);
        if (r) {
-               release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
+               release_region(scx200_cb_base + SCx200_WDT_OFFSET,
                                SCx200_WDT_SIZE);
                return r;
        }
@@ -260,7 +242,7 @@ static int __init scx200_wdt_init(void)
        if (r) {
                printk(KERN_ERR NAME ": unable to register reboot notifier");
                misc_deregister(&scx200_wdt_miscdev);
-               release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
+               release_region(scx200_cb_base + SCx200_WDT_OFFSET,
                                SCx200_WDT_SIZE);
                return r;
        }
@@ -272,7 +254,7 @@ static void __exit scx200_wdt_cleanup(void)
 {
        unregister_reboot_notifier(&scx200_wdt_notifier);
        misc_deregister(&scx200_wdt_miscdev);
-       release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
+       release_region(scx200_cb_base + SCx200_WDT_OFFSET,
                       SCx200_WDT_SIZE);
 }