Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0349a363e23a0533e081ca320c837bc08247343e
Commit:     0349a363e23a0533e081ca320c837bc08247343e
Parent:     1d747be647c2239e39a9b5faa138c1e36222b37e
Author:     Wim Van Sebroeck <[EMAIL PROTECTED]>
AuthorDate: Thu Jan 11 22:27:51 2007 +0100
Committer:  Wim Van Sebroeck <[EMAIL PROTECTED]>
CommitDate: Thu Jan 11 22:27:51 2007 +0100

    [WATCHDOG] advantechwdt.c - move set_heartbeat to a seperate function
    
    Put the set_heartbeat/timeout code into a seperate function
    
    Signed-off-by: Wim Van Sebroeck <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/advantechwdt.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/char/watchdog/advantechwdt.c 
b/drivers/char/watchdog/advantechwdt.c
index 6c91979..216af0d 100644
--- a/drivers/char/watchdog/advantechwdt.c
+++ b/drivers/char/watchdog/advantechwdt.c
@@ -95,6 +95,16 @@ advwdt_disable(void)
        inb_p(wdt_stop);
 }
 
+static int
+advwdt_set_heartbeat(int t)
+{
+       if ((t < 1) || (t > 63))
+               return -EINVAL;
+
+       timeout = t;
+       return 0;
+}
+
 /*
  *     /dev/watchdog handling
  */
@@ -151,9 +161,8 @@ advwdt_ioctl(struct inode *inode, struct file *file, 
unsigned int cmd,
        case WDIOC_SETTIMEOUT:
          if (get_user(new_timeout, p))
                  return -EFAULT;
-         if ((new_timeout < 1) || (new_timeout > 63))
+         if (advwdt_set_heartbeat(new_timeout))
                  return -EINVAL;
-         timeout = new_timeout;
          advwdt_ping();
          /* Fall */
 
@@ -267,12 +276,6 @@ advwdt_init(void)
 
        printk(KERN_INFO "WDT driver for Advantech single board computer 
initialising.\n");
 
-       if (timeout < 1 || timeout > 63) {
-               timeout = WATCHDOG_TIMEOUT;
-               printk (KERN_INFO PFX "timeout value must be 1<=x<=63, using 
%d\n",
-                       timeout);
-       }
-
        if (wdt_stop != wdt_start) {
                if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
                        printk (KERN_ERR PFX "I/O address 0x%04x already in 
use\n",
@@ -289,6 +292,13 @@ advwdt_init(void)
                goto unreg_stop;
        }
 
+       /* Check that the heartbeat value is within it's range ; if not reset 
to the default */
+       if (advwdt_set_heartbeat(timeout)) {
+               advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
+               printk (KERN_INFO PFX "timeout value must be 1<=x<=63, using 
%d\n",
+                       timeout);
+       }
+
        ret = register_reboot_notifier(&advwdt_notifier);
        if (ret != 0) {
                printk (KERN_ERR PFX "cannot register reboot notifier 
(err=%d)\n",
-
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