X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fwatchdog%2Fomap_wdt.c;h=3a11dadfd8e7dba34103f9d9b8685648e14a6f31;hb=3f30a09a612bac2b531a206c2a58a292dd7ff182;hp=74bc39aa1ce87b1b7715e88e1c11ab4f114a94d4;hpb=f838bad1b3be8ca0c785ee0e0c570dfda74cf377;p=linux-2.6-omap-h63xx.git diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 74bc39aa1ce..3a11dadfd8e 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -40,12 +40,10 @@ #include #include #include - -#include -#include -#include - -#include +#include +#include +#include +#include #include "omap_wdt.h" @@ -54,11 +52,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,30 +173,29 @@ 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, }; switch (cmd) { - default: - return -ENOTTY; case WDIOC_GETSUPPORT: return copy_to_user((struct watchdog_info __user *)arg, &ident, sizeof(ident)); @@ -211,28 +209,34 @@ 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); + default: + return -ENOTTY; } } 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, }; @@ -240,7 +244,7 @@ static const struct file_operations omap_wdt_fops = { static struct miscdevice omap_wdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &omap_wdt_fops + .fops = &omap_wdt_fops, }; static int __init omap_wdt_probe(struct platform_device *pdev) @@ -373,6 +377,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); }