summaryrefslogtreecommitdiff
path: root/packages/linux/linux-mtx-1-2.4.27/23-mtx-1_watchdog_autotrigger.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packages/linux/linux-mtx-1-2.4.27/23-mtx-1_watchdog_autotrigger.patch')
-rw-r--r--packages/linux/linux-mtx-1-2.4.27/23-mtx-1_watchdog_autotrigger.patch98
1 files changed, 98 insertions, 0 deletions
diff --git a/packages/linux/linux-mtx-1-2.4.27/23-mtx-1_watchdog_autotrigger.patch b/packages/linux/linux-mtx-1-2.4.27/23-mtx-1_watchdog_autotrigger.patch
new file mode 100644
index 0000000000..c6bb0aae68
--- /dev/null
+++ b/packages/linux/linux-mtx-1-2.4.27/23-mtx-1_watchdog_autotrigger.patch
@@ -0,0 +1,98 @@
+--- linux/arch/mips/au1000/mtx-1/mtx-1_watchdog.c.orig 2005-03-22 17:18:01.000000000 +0100
++++ linux/arch/mips/au1000/mtx-1/mtx-1_watchdog.c 2005-07-06 12:10:06.000000000 +0200
+@@ -39,6 +39,7 @@
+ #include <linux/watchdog.h>
+ #include <linux/slab.h>
+ #include <linux/init.h>
++#include <asm/uaccess.h>
+
+ #include <asm/au1000.h>
+
+@@ -115,6 +116,8 @@
+
+ //---------[ File Functions ]-----------------
+
++static char restart_after_close;
++
+ static int mtx1wd_open (struct inode *inode, struct file *file)
+ {
+ if (MINOR(inode->i_rdev)!=WATCHDOG_MINOR) return -ENODEV;
+@@ -134,6 +137,10 @@
+
+ static int mtx1wd_release (struct inode *inode, struct file *file) {
+ if (MINOR(inode->i_rdev)==WATCHDOG_MINOR) {
++
++ if (restart_after_close)
++ start_wd_timer ();
++
+ }
+ MOD_DEC_USE_COUNT;
+ return 0;
+@@ -141,22 +148,53 @@
+
+
+ static ssize_t mtx1wd_write (struct file *file, const char *buf, size_t count, loff_t *ppos) {
+- if (ppos!=&file->f_pos)
+- return -ESPIPE;
+
+- if (count) {
+ mtx1_trigger_wd ();
+- return 1;
++
++ if (count > 0) {
++ char buffer[10];
++ int n = (count>9)?9:count;
++
++ if (copy_from_user (&buffer, buf, n))
++ return -EFAULT;
++ buffer[n]=0;
++
++ if (count >= 4 && strncmp("auto", buffer, 4)==0)
++ restart_after_close = 1;
++
++ else if (count >= 6 && strncmp("manual", buffer, 6)==0)
++ restart_after_close = 0;
++
++ return n;
+ }
+ return 0;
+ }
+
+
++static ssize_t mtx1wd_read (struct file *file, char *buf, size_t count, loff_t *ppos)
++{
++ char * state = restart_after_close ? "auto\n" : "manual\n";
++ int n = strlen(state)+1;
++
++ if (file->f_pos >= n)
++ return 0;
++
++ if (count < n)
++ return -EINVAL;
++
++ if(copy_to_user(buf, state, n))
++ return -EFAULT;
++
++ file->f_pos += n;
++
++ return n;
++}
++
+
+ static struct file_operations mtx1wd_fops = {
+ .owner = THIS_MODULE,
+ .llseek = NULL,
+- .read = NULL,
++ .read = mtx1wd_read,
+ .write = mtx1wd_write,
+ .readdir = NULL,
+ .poll = NULL,
+@@ -194,6 +232,8 @@
+ {
+ printk("MTX-1 watchdog driver\n");
+
++ restart_after_close = 0;
++
+ mtx1_enable_wd ();
+
+ //-- trigger it for the first time.