Commit e7d9aa2a authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[WATCHDOG] indydog nowayout fixes from 2.4

parent a1da6411
...@@ -26,6 +26,16 @@ ...@@ -26,6 +26,16 @@
static unsigned long indydog_alive; static unsigned long indydog_alive;
static struct sgimc_misc_ctrl *mcmisc_regs; static struct sgimc_misc_ctrl *mcmisc_regs;
static int expect_close = 0;
#ifdef CONFIG_WATCHDOG_NOWAYOUT
static int nowayout = 1;
#else
static int nowayout = 0;
#endif
MODULE_PARM(nowayout,"i");
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
static void indydog_ping() static void indydog_ping()
{ {
...@@ -43,9 +53,10 @@ static int indydog_open(struct inode *inode, struct file *file) ...@@ -43,9 +53,10 @@ static int indydog_open(struct inode *inode, struct file *file)
if( test_and_set_bit(0,&indydog_alive) ) if( test_and_set_bit(0,&indydog_alive) )
return -EBUSY; return -EBUSY;
#ifdef CONFIG_WATCHDOG_NOWAYOUT
if (nowayout)
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
#endif
/* /*
* Activate timer * Activate timer
*/ */
...@@ -63,16 +74,17 @@ static int indydog_release(struct inode *inode, struct file *file) ...@@ -63,16 +74,17 @@ static int indydog_release(struct inode *inode, struct file *file)
{ {
/* /*
* Shut off the timer. * Shut off the timer.
* Lock it in if it's a module and we defined ...NOWAYOUT * Lock it in if it's a module and we set nowayout
*/ */
#ifndef CONFIG_WATCHDOG_NOWAYOUT
{ if (expect_close) {
u32 mc_ctrl0 = mcmisc_regs->cpuctrl0; u32 mc_ctrl0 = mcmisc_regs->cpuctrl0;
mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG; mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG;
mcmisc_regs->cpuctrl0 = mc_ctrl0; mcmisc_regs->cpuctrl0 = mc_ctrl0;
printk("Stopped watchdog timer.\n"); printk("Stopped watchdog timer.\n");
} else {
printk(KERN_CRIT "WDT device closed unexpectedly. WDT will not stop!\n");
} }
#endif
clear_bit(0,&indydog_alive); clear_bit(0,&indydog_alive);
return 0; return 0;
} }
...@@ -83,10 +95,23 @@ static ssize_t indydog_write(struct file *file, const char *data, size_t len, lo ...@@ -83,10 +95,23 @@ static ssize_t indydog_write(struct file *file, const char *data, size_t len, lo
if (ppos != &file->f_pos) if (ppos != &file->f_pos)
return -ESPIPE; return -ESPIPE;
/* /* Refresh the timer. */
* Refresh the timer. if (len) {
*/ if (!nowayout) {
if(len) { size_t i;
/* In case it was set long ago */
expect_close = 0;
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
}
}
indydog_ping(); indydog_ping();
return 1; return 1;
} }
...@@ -97,8 +122,10 @@ static int indydog_ioctl(struct inode *inode, struct file *file, ...@@ -97,8 +122,10 @@ static int indydog_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
static struct watchdog_info ident = { static struct watchdog_info ident = {
identity: "Hardware Watchdog for SGI IP22", .options = WDIOF_MAGICCLOSE,
.identity = "Hardware Watchdog for SGI IP22",
}; };
switch (cmd) { switch (cmd) {
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment