]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[WATCHDOG 30/57] omap_wdt: locking, unlocked_ioctl, tidy
authorAlan Cox <alan@redhat.com>
Mon, 19 May 2008 13:07:32 +0000 (14:07 +0100)
committerWim Van Sebroeck <wim@iguana.be>
Fri, 13 Jun 2008 20:07:20 +0000 (20:07 +0000)
Review and switch to unlocked_ioctl

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/omap_wdt.c

index 74bc39aa1ce87b1b7715e88e1c11ab4f114a94d4..ccdf069792d91ab6574dbdfb24252d70aa5d8fb1 100644 (file)
@@ -41,9 +41,9 @@
 #include <linux/clk.h>
 #include <linux/bitops.h>
 
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/hardware.h>
+#include </io.h>
+#include <linux/uaccess.h>
+#include <linux/hardware.h>
 
 #include <asm/arch/prcm.h>
 
@@ -54,11 +54,12 @@ module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
 
 static int omap_wdt_users;
-static struct clk *armwdt_ck = NULL;
-static struct clk *mpu_wdt_ick = NULL;
-static struct clk *mpu_wdt_fck = NULL;
+static struct clk *armwdt_ck;
+static struct clk *mpu_wdt_ick;
+static struct clk *mpu_wdt_fck;
 
 static unsigned int wdt_trgr_pattern = 0x1234;
+static spinlock_t wdt_lock;
 
 static void omap_wdt_ping(void)
 {
@@ -174,22 +175,23 @@ static int omap_wdt_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-static ssize_t
-omap_wdt_write(struct file *file, const char __user *data,
+static ssize_t omap_wdt_write(struct file *file, const char __user *data,
                size_t len, loff_t *ppos)
 {
        /* Refresh LOAD_TIME. */
-       if (len)
+       if (len) {
+               spin_lock(&wdt_lock);
                omap_wdt_ping();
+               spin_unlock(&wdt_lock);
+       }
        return len;
 }
 
-static int
-omap_wdt_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg)
+static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
+                                               unsigned long arg)
 {
        int new_margin;
-       static struct watchdog_info ident = {
+       static const struct watchdog_info ident = {
                .identity = "OMAP Watchdog",
                .options = WDIOF_SETTIMEOUT,
                .firmware_version = 0,
@@ -211,18 +213,22 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
                        return put_user(omap_prcm_get_reset_sources(),
                                        (int __user *)arg);
        case WDIOC_KEEPALIVE:
+               spin_lock(&wdt_lock);
                omap_wdt_ping();
+               spin_unlock(&wdt_lock);
                return 0;
        case WDIOC_SETTIMEOUT:
                if (get_user(new_margin, (int __user *)arg))
                        return -EFAULT;
                omap_wdt_adjust_timeout(new_margin);
 
+               spin_lock(&wdt_lock);
                omap_wdt_disable();
                omap_wdt_set_timeout();
                omap_wdt_enable();
 
                omap_wdt_ping();
+               spin_unlock(&wdt_lock);
                /* Fall */
        case WDIOC_GETTIMEOUT:
                return put_user(timer_margin, (int __user *)arg);
@@ -232,7 +238,7 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
 static const struct file_operations omap_wdt_fops = {
        .owner = THIS_MODULE,
        .write = omap_wdt_write,
-       .ioctl = omap_wdt_ioctl,
+       .unlocked_ioctl = omap_wdt_ioctl,
        .open = omap_wdt_open,
        .release = omap_wdt_release,
 };
@@ -373,6 +379,7 @@ static struct platform_driver omap_wdt_driver = {
 
 static int __init omap_wdt_init(void)
 {
+       spin_lock_init(&wdt_lock);
        return platform_driver_register(&omap_wdt_driver);
 }