]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/watchdog/advantechwdt.c
Merge tag 'split-asm_system_h-for-linus-20120328' of git://git.kernel.org/pub/scm...
[linux-2.6.git] / drivers / watchdog / advantechwdt.c
index e6bf8d2d3d309ddd45b7b7289a7fb225e22342d4..64ae9e9fed94acdddab23d0d20ea50f771685ef3 100644 (file)
@@ -6,8 +6,8 @@
  *     Based on acquirewdt.c which is based on wdt.c.
  *     Original copyright messages:
  *
- *     (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
- *                             http://www.redhat.com
+ *     (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
+ *                                             All Rights Reserved.
  *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
  *     warranty for any of this software. This material is provided
  *     "AS-IS" and at no charge.
  *
- *     (c) Copyright 1995    Alan Cox <alan@redhat.com>
+ *     (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
  *     14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
  *         Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
@@ -28,6 +28,8 @@
  *         add wdt_start and wdt_stop as parameters.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
 
-#include <asm/system.h>
 
 #define DRV_NAME "advantechwdt"
-#define PFX DRV_NAME ": "
 #define WATCHDOG_NAME "Advantech WDT"
 #define WATCHDOG_TIMEOUT 60            /* 60 sec default timeout */
 
-static struct platform_device *advwdt_platform_device; /* the watchdog platform device */
+/* the watchdog platform device */
+static struct platform_device *advwdt_platform_device;
 static unsigned long advwdt_is_open;
 static char adv_expect_close;
 
@@ -76,8 +77,8 @@ MODULE_PARM_DESC(timeout,
        "Watchdog timeout in seconds. 1<= timeout <=63, default="
                __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
-static int nowayout = WATCHDOG_NOWAYOUT;
-module_param(nowayout, int, 0);
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
 MODULE_PARM_DESC(nowayout,
        "Watchdog cannot be stopped once started (default="
                __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
@@ -120,7 +121,7 @@ static ssize_t advwdt_write(struct file *file, const char __user *buf,
 
                        for (i = 0; i != count; i++) {
                                char c;
-                               if (get_user(c, buf+i))
+                               if (get_user(c, buf + i))
                                        return -EFAULT;
                                if (c == 'V')
                                        adv_expect_close = 42;
@@ -136,8 +137,10 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        int new_timeout;
        void __user *argp = (void __user *)arg;
        int __user *p = argp;
-       static struct watchdog_info ident = {
-               .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
+       static const struct watchdog_info ident = {
+               .options = WDIOF_KEEPALIVEPING |
+                          WDIOF_SETTIMEOUT |
+                          WDIOF_MAGICCLOSE,
                .firmware_version = 1,
                .identity = WATCHDOG_NAME,
        };
@@ -152,19 +155,6 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case WDIOC_GETBOOTSTATUS:
                return put_user(0, p);
 
-       case WDIOC_KEEPALIVE:
-               advwdt_ping();
-               break;
-
-       case WDIOC_SETTIMEOUT:
-               if (get_user(new_timeout, p))
-                       return -EFAULT;
-               if (advwdt_set_heartbeat(new_timeout))
-                       return -EINVAL;
-               advwdt_ping();
-               /* Fall */
-       case WDIOC_GETTIMEOUT:
-               return put_user(timeout, p);
        case WDIOC_SETOPTIONS:
        {
                int options, retval = -EINVAL;
@@ -181,6 +171,19 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                }
                return retval;
        }
+       case WDIOC_KEEPALIVE:
+               advwdt_ping();
+               break;
+
+       case WDIOC_SETTIMEOUT:
+               if (get_user(new_timeout, p))
+                       return -EFAULT;
+               if (advwdt_set_heartbeat(new_timeout))
+                       return -EINVAL;
+               advwdt_ping();
+               /* Fall */
+       case WDIOC_GETTIMEOUT:
+               return put_user(timeout, p);
        default:
                return -ENOTTY;
        }
@@ -199,14 +202,12 @@ static int advwdt_open(struct inode *inode, struct file *file)
        return nonseekable_open(inode, file);
 }
 
-static int
-advwdt_close(struct inode *inode, struct file *file)
+static int advwdt_close(struct inode *inode, struct file *file)
 {
        if (adv_expect_close == 42) {
                advwdt_disable();
        } else {
-               printk(KERN_CRIT PFX
-                               "Unexpected close, not stopping watchdog!\n");
+               pr_crit("Unexpected close, not stopping watchdog!\n");
                advwdt_ping();
        }
        clear_bit(0, &advwdt_is_open);
@@ -243,37 +244,33 @@ static int __devinit advwdt_probe(struct platform_device *dev)
 
        if (wdt_stop != wdt_start) {
                if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
-                       printk(KERN_ERR PFX
-                               "I/O address 0x%04x already in use\n",
-                                                               wdt_stop);
+                       pr_err("I/O address 0x%04x already in use\n",
+                              wdt_stop);
                        ret = -EIO;
                        goto out;
                }
        }
 
        if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
-               printk(KERN_ERR PFX
-                               "I/O address 0x%04x already in use\n",
-                                                               wdt_start);
+               pr_err("I/O address 0x%04x already in use\n", wdt_start);
                ret = -EIO;
                goto unreg_stop;
        }
 
-       /* Check that the heartbeat value is within it's range ; if not reset to the default */
+       /* Check that the heartbeat value is within it's range ;
+        * if not reset to the default */
        if (advwdt_set_heartbeat(timeout)) {
                advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
-               printk(KERN_INFO PFX
-                       "timeout value must be 1<=x<=63, using %d\n", timeout);
+               pr_info("timeout value must be 1<=x<=63, using %d\n", timeout);
        }
 
        ret = misc_register(&advwdt_miscdev);
        if (ret != 0) {
-               printk(KERN_ERR PFX
-                       "cannot register miscdev on minor=%d (err=%d)\n",
-                                                       WATCHDOG_MINOR, ret);
+               pr_err("cannot register miscdev on minor=%d (err=%d)\n",
+                      WATCHDOG_MINOR, ret);
                goto unreg_regions;
        }
-       printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
+       pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
                timeout, nowayout);
 out:
        return ret;
@@ -288,9 +285,9 @@ unreg_stop:
 static int __devexit advwdt_remove(struct platform_device *dev)
 {
        misc_deregister(&advwdt_miscdev);
-       release_region(wdt_start,1);
-       if(wdt_stop != wdt_start)
-               release_region(wdt_stop,1);
+       release_region(wdt_start, 1);
+       if (wdt_stop != wdt_start)
+               release_region(wdt_stop, 1);
 
        return 0;
 }
@@ -315,7 +312,7 @@ static int __init advwdt_init(void)
 {
        int err;
 
-       printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n");
+       pr_info("WDT driver for Advantech single board computer initialising\n");
 
        err = platform_driver_register(&advwdt_driver);
        if (err)
@@ -339,7 +336,7 @@ static void __exit advwdt_exit(void)
 {
        platform_device_unregister(advwdt_platform_device);
        platform_driver_unregister(&advwdt_driver);
-       printk(KERN_INFO PFX "Watchdog Module Unloaded.\n");
+       pr_info("Watchdog Module Unloaded\n");
 }
 
 module_init(advwdt_init);