X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fwatchdog%2Fs3c2410_wdt.c;h=b57ac6b49147400a0230a777b81592202947a439;hb=8494347eedd2facf474021c615d1d07c62e04afd;hp=44bf5e4282e1e089ae7ba486c67e52b1e1d62a7e;hpb=0c06090c9472db0525cb6fe229c3bea33bbbbb3c;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 44bf5e4..b57ac6b 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -6,7 +6,7 @@ * S3C2410 Watchdog Timer Support * * Based on, softdog.c by Alan Cox, - * (c) Copyright 1996 Alan Cox + * (c) Copyright 1996 Alan Cox * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,18 +21,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Changelog: - * 05-Oct-2004 BJD Added semaphore init to stop crashes on open - * Fixed tmr_count / wdt_count confusion - * Added configurable debug - * - * 11-Jan-2005 BJD Fixed divide-by-2 in timeout code - * - * 25-Jan-2005 DA Added suspend/resume support - * Replaced reboot notifier with .shutdown method - * - * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA */ #include @@ -49,12 +37,12 @@ #include #include -#include +#include #undef S3C_VA_WATCHDOG #define S3C_VA_WATCHDOG (0) -#include +#include #define PFX "s3c2410-wdt: " @@ -80,15 +68,10 @@ MODULE_PARM_DESC(tmr_atboot, __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT)); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); -MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)"); +MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, " + "0 to reboot (default depends on ONLY_TESTING)"); MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)"); - -typedef enum close_state { - CLOSE_STATE_NOT, - CLOSE_STATE_ALLOW = 0x4021 -} close_state_t; - static unsigned long open_lock; static struct device *wdt_dev; /* platform device attached to */ static struct resource *wdt_mem; @@ -96,7 +79,7 @@ static struct resource *wdt_irq; static struct clk *wdt_clock; static void __iomem *wdt_base; static unsigned int wdt_count; -static close_state_t allow_close; +static char expect_close; static DEFINE_SPINLOCK(wdt_lock); /* watchdog control routines */ @@ -119,17 +102,6 @@ static void __s3c2410wdt_stop(void) { unsigned long wtcon; - spin_lock(&wdt_lock); - wtcon = readl(wdt_base + S3C2410_WTCON); - wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN); - writel(wtcon, wdt_base + S3C2410_WTCON); - spin_unlock(&wdt_lock); -} - -static void __s3c2410wdt_stop(void) -{ - unsigned long wtcon; - wtcon = readl(wdt_base + S3C2410_WTCON); wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN); writel(wtcon, wdt_base + S3C2410_WTCON); @@ -168,8 +140,6 @@ static void s3c2410wdt_start(void) writel(wdt_count, wdt_base + S3C2410_WTCNT); writel(wtcon, wdt_base + S3C2410_WTCON); spin_unlock(&wdt_lock); - - return 0; } static int s3c2410wdt_set_heartbeat(int timeout) @@ -236,7 +206,7 @@ static int s3c2410wdt_open(struct inode *inode, struct file *file) if (nowayout) __module_get(THIS_MODULE); - allow_close = CLOSE_STATE_NOT; + expect_close = 0; /* start the timer */ s3c2410wdt_start(); @@ -250,13 +220,13 @@ static int s3c2410wdt_release(struct inode *inode, struct file *file) * Lock it in if it's a module and we set nowayout */ - if (allow_close == CLOSE_STATE_ALLOW) + if (expect_close == 42) s3c2410wdt_stop(); else { dev_err(wdt_dev, "Unexpected close, not stopping watchdog\n"); s3c2410wdt_keepalive(); } - allow_close = CLOSE_STATE_NOT; + expect_close = 0; clear_bit(0, &open_lock); return 0; } @@ -272,7 +242,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data, size_t i; /* In case it was set long ago */ - allow_close = CLOSE_STATE_NOT; + expect_close = 0; for (i = 0; i != len; i++) { char c; @@ -280,7 +250,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data, if (get_user(c, data + i)) return -EFAULT; if (c == 'V') - allow_close = CLOSE_STATE_ALLOW; + expect_close = 42; } } s3c2410wdt_keepalive(); @@ -288,7 +258,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data, return len; } -#define OPTIONS WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE +#define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE) static const struct watchdog_info s3c2410_wdt_ident = { .options = OPTIONS, @@ -356,7 +326,7 @@ static irqreturn_t s3c2410wdt_irq(int irqno, void *param) } /* device interface */ -static int s3c2410wdt_probe(struct platform_device *pdev) +static int __devinit s3c2410wdt_probe(struct platform_device *pdev) { struct resource *res; struct device *dev; @@ -378,7 +348,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) return -ENOENT; } - size = (res->end-res->start)+1; + size = (res->end - res->start) + 1; wdt_mem = request_mem_region(res->start, size, pdev->name); if (wdt_mem == NULL) { dev_err(dev, "failed to get memory region\n"); @@ -387,7 +357,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) } wdt_base = ioremap(res->start, size); - if (wdt_base == 0) { + if (wdt_base == NULL) { dev_err(dev, "failed to ioremap() region\n"); ret = -EINVAL; goto err_req; @@ -429,7 +399,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev) "tmr_margin value out of range, default %d used\n", CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); else - dev_info(dev, "default timer value is out of range, cannot start\n"); + dev_info(dev, "default timer value is out of range, " + "cannot start\n"); } ret = misc_register(&s3c2410wdt_miscdev); @@ -478,7 +449,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) return ret; } -static int s3c2410wdt_remove(struct platform_device *dev) +static int __devexit s3c2410wdt_remove(struct platform_device *dev) { release_resource(wdt_mem); kfree(wdt_mem); @@ -540,7 +511,7 @@ static int s3c2410wdt_resume(struct platform_device *dev) static struct platform_driver s3c2410wdt_driver = { .probe = s3c2410wdt_probe, - .remove = s3c2410wdt_remove, + .remove = __devexit_p(s3c2410wdt_remove), .shutdown = s3c2410wdt_shutdown, .suspend = s3c2410wdt_suspend, .resume = s3c2410wdt_resume,