aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/s3c2410_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/s3c2410_wdt.c')
-rw-r--r--drivers/watchdog/s3c2410_wdt.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index e31925ee8346..b57ac6b49147 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -68,15 +68,10 @@ MODULE_PARM_DESC(tmr_atboot,
68 __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT)); 68 __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT));
69MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 69MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
70 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 70 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
71MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)"); 71MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, "
72 "0 to reboot (default depends on ONLY_TESTING)");
72MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)"); 73MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)");
73 74
74
75typedef enum close_state {
76 CLOSE_STATE_NOT,
77 CLOSE_STATE_ALLOW = 0x4021
78} close_state_t;
79
80static unsigned long open_lock; 75static unsigned long open_lock;
81static struct device *wdt_dev; /* platform device attached to */ 76static struct device *wdt_dev; /* platform device attached to */
82static struct resource *wdt_mem; 77static struct resource *wdt_mem;
@@ -84,7 +79,7 @@ static struct resource *wdt_irq;
84static struct clk *wdt_clock; 79static struct clk *wdt_clock;
85static void __iomem *wdt_base; 80static void __iomem *wdt_base;
86static unsigned int wdt_count; 81static unsigned int wdt_count;
87static close_state_t allow_close; 82static char expect_close;
88static DEFINE_SPINLOCK(wdt_lock); 83static DEFINE_SPINLOCK(wdt_lock);
89 84
90/* watchdog control routines */ 85/* watchdog control routines */
@@ -211,7 +206,7 @@ static int s3c2410wdt_open(struct inode *inode, struct file *file)
211 if (nowayout) 206 if (nowayout)
212 __module_get(THIS_MODULE); 207 __module_get(THIS_MODULE);
213 208
214 allow_close = CLOSE_STATE_NOT; 209 expect_close = 0;
215 210
216 /* start the timer */ 211 /* start the timer */
217 s3c2410wdt_start(); 212 s3c2410wdt_start();
@@ -225,13 +220,13 @@ static int s3c2410wdt_release(struct inode *inode, struct file *file)
225 * Lock it in if it's a module and we set nowayout 220 * Lock it in if it's a module and we set nowayout
226 */ 221 */
227 222
228 if (allow_close == CLOSE_STATE_ALLOW) 223 if (expect_close == 42)
229 s3c2410wdt_stop(); 224 s3c2410wdt_stop();
230 else { 225 else {
231 dev_err(wdt_dev, "Unexpected close, not stopping watchdog\n"); 226 dev_err(wdt_dev, "Unexpected close, not stopping watchdog\n");
232 s3c2410wdt_keepalive(); 227 s3c2410wdt_keepalive();
233 } 228 }
234 allow_close = CLOSE_STATE_NOT; 229 expect_close = 0;
235 clear_bit(0, &open_lock); 230 clear_bit(0, &open_lock);
236 return 0; 231 return 0;
237} 232}
@@ -247,7 +242,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
247 size_t i; 242 size_t i;
248 243
249 /* In case it was set long ago */ 244 /* In case it was set long ago */
250 allow_close = CLOSE_STATE_NOT; 245 expect_close = 0;
251 246
252 for (i = 0; i != len; i++) { 247 for (i = 0; i != len; i++) {
253 char c; 248 char c;
@@ -255,7 +250,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
255 if (get_user(c, data + i)) 250 if (get_user(c, data + i))
256 return -EFAULT; 251 return -EFAULT;
257 if (c == 'V') 252 if (c == 'V')
258 allow_close = CLOSE_STATE_ALLOW; 253 expect_close = 42;
259 } 254 }
260 } 255 }
261 s3c2410wdt_keepalive(); 256 s3c2410wdt_keepalive();
@@ -263,7 +258,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
263 return len; 258 return len;
264} 259}
265 260
266#define OPTIONS WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE 261#define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE)
267 262
268static const struct watchdog_info s3c2410_wdt_ident = { 263static const struct watchdog_info s3c2410_wdt_ident = {
269 .options = OPTIONS, 264 .options = OPTIONS,
@@ -331,7 +326,7 @@ static irqreturn_t s3c2410wdt_irq(int irqno, void *param)
331} 326}
332/* device interface */ 327/* device interface */
333 328
334static int s3c2410wdt_probe(struct platform_device *pdev) 329static int __devinit s3c2410wdt_probe(struct platform_device *pdev)
335{ 330{
336 struct resource *res; 331 struct resource *res;
337 struct device *dev; 332 struct device *dev;
@@ -404,7 +399,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
404 "tmr_margin value out of range, default %d used\n", 399 "tmr_margin value out of range, default %d used\n",
405 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); 400 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
406 else 401 else
407 dev_info(dev, "default timer value is out of range, cannot start\n"); 402 dev_info(dev, "default timer value is out of range, "
403 "cannot start\n");
408 } 404 }
409 405
410 ret = misc_register(&s3c2410wdt_miscdev); 406 ret = misc_register(&s3c2410wdt_miscdev);
@@ -453,7 +449,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
453 return ret; 449 return ret;
454} 450}
455 451
456static int s3c2410wdt_remove(struct platform_device *dev) 452static int __devexit s3c2410wdt_remove(struct platform_device *dev)
457{ 453{
458 release_resource(wdt_mem); 454 release_resource(wdt_mem);
459 kfree(wdt_mem); 455 kfree(wdt_mem);
@@ -515,7 +511,7 @@ static int s3c2410wdt_resume(struct platform_device *dev)
515 511
516static struct platform_driver s3c2410wdt_driver = { 512static struct platform_driver s3c2410wdt_driver = {
517 .probe = s3c2410wdt_probe, 513 .probe = s3c2410wdt_probe,
518 .remove = s3c2410wdt_remove, 514 .remove = __devexit_p(s3c2410wdt_remove),
519 .shutdown = s3c2410wdt_shutdown, 515 .shutdown = s3c2410wdt_shutdown,
520 .suspend = s3c2410wdt_suspend, 516 .suspend = s3c2410wdt_suspend,
521 .resume = s3c2410wdt_resume, 517 .resume = s3c2410wdt_resume,