linux.conf.au 2009: Tuz
[safe/jmp/linux-2.6] / drivers / watchdog / pnx4008_wdt.c
index 22f8873..6d9f3d4 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/spinlock.h>
-
-#include <asm/hardware.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include <mach/hardware.h>
 
 #define MODULE_NAME "PNX4008-WDT: "
 
@@ -80,7 +79,7 @@
 static int nowayout = WATCHDOG_NOWAYOUT;
 static int heartbeat = DEFAULT_HEARTBEAT;
 
-static spinlock_t io_lock;
+static DEFINE_SPINLOCK(io_lock);
 static unsigned long wdt_status;
 #define WDT_IN_USE        0
 #define WDT_OK_TO_CLOSE   1
@@ -144,9 +143,8 @@ static int pnx4008_wdt_open(struct inode *inode, struct file *file)
        return nonseekable_open(inode, file);
 }
 
-static ssize_t
-pnx4008_wdt_write(struct file *file, const char *data, size_t len,
-                 loff_t * ppos)
+static ssize_t pnx4008_wdt_write(struct file *file, const char *data,
+                                       size_t len, loff_t *ppos)
 {
        if (len) {
                if (!nowayout) {
@@ -169,15 +167,14 @@ pnx4008_wdt_write(struct file *file, const char *data, size_t len,
        return len;
 }
 
-static struct watchdog_info ident = {
+static const struct watchdog_info ident = {
        .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE |
            WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
        .identity = "PNX4008 Watchdog",
 };
 
-static int
-pnx4008_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-                 unsigned long arg)
+static long pnx4008_wdt_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg)
 {
        int ret = -ENOTTY;
        int time;
@@ -196,6 +193,11 @@ pnx4008_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                ret = put_user(boot_status, (int *)arg);
                break;
 
+       case WDIOC_KEEPALIVE:
+               wdt_enable();
+               ret = 0;
+               break;
+
        case WDIOC_SETTIMEOUT:
                ret = get_user(time, (int *)arg);
                if (ret)
@@ -213,11 +215,6 @@ pnx4008_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        case WDIOC_GETTIMEOUT:
                ret = put_user(heartbeat, (int *)arg);
                break;
-
-       case WDIOC_KEEPALIVE:
-               wdt_enable();
-               ret = 0;
-               break;
        }
        return ret;
 }
@@ -238,7 +235,7 @@ static const struct file_operations pnx4008_wdt_fops = {
        .owner = THIS_MODULE,
        .llseek = no_llseek,
        .write = pnx4008_wdt_write,
-       .ioctl = pnx4008_wdt_ioctl,
+       .unlocked_ioctl = pnx4008_wdt_ioctl,
        .open = pnx4008_wdt_open,
        .release = pnx4008_wdt_release,
 };
@@ -254,8 +251,6 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
        int ret = 0, size;
        struct resource *res;
 
-       spin_lock_init(&io_lock);
-
        if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
                heartbeat = DEFAULT_HEARTBEAT;
 
@@ -323,6 +318,7 @@ static int pnx4008_wdt_remove(struct platform_device *pdev)
 static struct platform_driver platform_wdt_driver = {
        .driver = {
                .name = "watchdog",
+               .owner  = THIS_MODULE,
        },
        .probe = pnx4008_wdt_probe,
        .remove = pnx4008_wdt_remove,
@@ -335,7 +331,7 @@ static int __init pnx4008_wdt_init(void)
 
 static void __exit pnx4008_wdt_exit(void)
 {
-       return platform_driver_unregister(&platform_wdt_driver);
+       platform_driver_unregister(&platform_wdt_driver);
 }
 
 module_init(pnx4008_wdt_init);
@@ -356,3 +352,4 @@ MODULE_PARM_DESC(nowayout,
 
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+MODULE_ALIAS("platform:watchdog");