Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=35d55c943117864b9dff0253eb64672f048ac0f8
Commit:     35d55c943117864b9dff0253eb64672f048ac0f8
Parent:     bffda5c87cf60d27a27f2e862c82c474f8e89767
Author:     Wim Van Sebroeck <[EMAIL PROTECTED]>
AuthorDate: Sat Jan 27 21:50:53 2007 +0100
Committer:  Wim Van Sebroeck <[EMAIL PROTECTED]>
CommitDate: Sat Jan 27 21:50:53 2007 +0100

    [WATCHDOG] ib700_wdt.c stop + set_heartbeat operations
    
    move the code to stop the watchdog and the code to
    set the heartbeat of the watchdog to seperate functions.
    
    Signed-off-by: Wim Van Sebroeck <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/ib700wdt.c |   39 +++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
index 0c3c3a3..5510db2 100644
--- a/drivers/char/watchdog/ib700wdt.c
+++ b/drivers/char/watchdog/ib700wdt.c
@@ -122,7 +122,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once 
started (default=" _
 
 
 /*
- *     Kernel methods.
+ *     Watchdog Operations
  */
 
 static void
@@ -132,6 +132,31 @@ ibwdt_ping(void)
        outb_p(wd_margin, WDT_START);
 }
 
+static void
+ibwdt_disable(void)
+{
+       outb_p(0, WDT_STOP);
+}
+
+static int
+ibwdt_set_heartbeat(int t)
+{
+       int i;
+
+       if ((t < 0) || (t > 30))
+               return -EINVAL;
+
+       for (i = 0x0F; i > -1; i--)
+               if (wd_times[i] > t)
+                       break;
+       wd_margin = i;
+       return 0;
+}
+
+/*
+ *     /dev/watchdog handling
+ */
+
 static ssize_t
 ibwdt_write(struct file *file, const char __user *buf, size_t count, loff_t 
*ppos)
 {
@@ -159,7 +184,7 @@ static int
 ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
          unsigned long arg)
 {
-       int i, new_margin;
+       int new_margin;
        void __user *argp = (void __user *)arg;
        int __user *p = argp;
 
@@ -185,12 +210,8 @@ ibwdt_ioctl(struct inode *inode, struct file *file, 
unsigned int cmd,
        case WDIOC_SETTIMEOUT:
          if (get_user(new_margin, p))
                  return -EFAULT;
-         if ((new_margin < 0) || (new_margin > 30))
+         if (ibwdt_set_heartbeat(new_margin))
                  return -EINVAL;
-         for (i = 0x0F; i > -1; i--)
-                 if (wd_times[i] > new_margin)
-                         break;
-         wd_margin = i;
          ibwdt_ping();
          /* Fall */
 
@@ -226,7 +247,7 @@ ibwdt_close(struct inode *inode, struct file *file)
 {
        spin_lock(&ibwdt_lock);
        if (expect_close == 42)
-               outb_p(0, WDT_STOP);
+               ibwdt_disable();
        else
                printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will 
not stop!\n");
 
@@ -246,7 +267,7 @@ ibwdt_notify_sys(struct notifier_block *this, unsigned long 
code,
 {
        if (code == SYS_DOWN || code == SYS_HALT) {
                /* Turn the WDT off */
-               outb_p(0, WDT_STOP);
+               ibwdt_disable();
        }
        return NOTIFY_DONE;
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to