Changeset 3666


Ignore:
Timestamp:
2006-04-17T20:39:32+02:00 (12 years ago)
Author:
mbm
Message:

cleanup watchdog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openwrt/target/linux/aruba-2.6/patches/004-wdt.patch

    r3655 r3666  
    22--- linux-2.6.15.1/drivers/char/watchdog/wdt_merlot.c   2006-01-26 21:14:02.204626250 -0800 
    33+++ linux-2.6.15.1-openwrt/drivers/char/watchdog/wdt_merlot.c   2006-02-02 20:31:43.000000000 -0800 
    4 @@ -0,0 +1,141 @@ 
     4@@ -0,0 +1,110 @@ 
    55+#include <linux/config.h> 
    66+#include <linux/module.h> 
     
    1515+#include <asm/bootinfo.h> 
    1616+ 
    17 +// refresh the watchdog timer for this many seconds in kernel 
    18 +// before letting the watchdog process take over. 
    19 +#define WDT_COUNT 60 
    20 + 
    2117+extern unsigned long mips_machtype; 
    2218+ 
    2319+static unsigned long wdt_is_open; 
    2420+static struct timer_list wdt_timer; 
    25 +static int wdt_count = WDT_COUNT; 
    2621+ 
    27 +static void wdt_merlot_refresh(void){ 
    28 +  volatile __u32 *wdt; 
    29 +  switch (mips_machtype) { 
    30 +  case MACH_ARUBA_AP70: 
    31 +    wdt = (__u32 *)0xb8030034; 
    32 +    *wdt = 0x10000000; 
    33 +    break; 
    34 +  default: 
    35 +    wdt = (__u32 *)0xbc00300c; 
    36 +    *wdt = 0x40000000; 
    37 +    break; 
    38 +  } 
     22+static void wdt_merlot_refresh(void) 
     23+{ 
     24+    volatile __u32 *wdt; 
     25+    switch (mips_machtype) { 
     26+    case MACH_ARUBA_AP70: 
     27+       wdt = (__u32 *) 0xb8030034; 
     28+       *wdt = 0x10000000; 
     29+       break; 
     30+    default: 
     31+       wdt = (__u32 *) 0xbc00300c; 
     32+       *wdt = 0x40000000; 
     33+       break; 
     34+    } 
    3935+} 
    4036+ 
    41 +static void wdt_merlot_disable() 
     37+static void wdt_merlot_timer_fn(unsigned long data) 
    4238+{ 
    43 +  volatile __u32 *wdt_errcs; 
    44 +  volatile __u32 *wdt_wtc; 
    45 +  volatile __u32 *wdt_ctl; 
    46 +  volatile __u32 val ; 
    47 + 
    48 +  switch (mips_machtype) { 
    49 +  case MACH_ARUBA_AP70: 
    50 +    wdt_errcs = (__u32 *)0xb8030030 ; 
    51 +    wdt_wtc   = (__u32 *)0xb803003c ; 
    52 +    val = *wdt_errcs ; 
    53 +    val &= ~0x201 ; 
    54 +    *wdt_errcs = val ; 
    55 +    val = *wdt_wtc ; 
    56 +    val &= ~0x1 ; 
    57 +    *wdt_wtc = val ; 
    58 +    break; 
    59 +  default: 
    60 +    wdt_ctl = (__u32 *)0xbc003008; 
    61 +    *wdt_ctl = 0 ; 
    62 +    break; 
    63 +  } 
     39+    wdt_merlot_refresh(); 
     40+    if (!test_bit(1, &wdt_is_open)) 
     41+       mod_timer(&wdt_timer, jiffies + HZ); 
    6442+} 
    6543+ 
    66 +static void wdt_merlot_timer_fn(unsigned long data){ 
     44+static int wdt_merlot_setup_timer(void) 
     45+{ 
    6746+ 
    68 +  wdt_merlot_refresh(); 
    69 +  if (--wdt_count >= 0) 
    70 +    mod_timer(&wdt_timer, jiffies + HZ); 
    71 +  else 
    72 +    wdt_merlot_disable(); 
    73 + 
    74 +} 
    75 + 
    76 +static int wdt_merlot_setup_timer(void){ 
    77 + 
    78 +  init_timer(&wdt_timer); 
    79 +  wdt_timer.function = wdt_merlot_timer_fn; 
    80 +  wdt_timer.data = 0; 
    81 +  wdt_timer.expires = jiffies + HZ; 
    82 +  add_timer(&wdt_timer); 
    83 +  return 0; 
     47+    init_timer(&wdt_timer); 
     48+    wdt_timer.function = wdt_merlot_timer_fn; 
     49+    wdt_timer.data = 0; 
     50+    wdt_timer.expires = jiffies + HZ; 
     51+    add_timer(&wdt_timer); 
     52+    return 0; 
    8453+} 
    8554+ 
    8655+static int wdt_open(struct inode *inode, struct file *file) 
    8756+{ 
    88 +       if(test_and_set_bit(0, &wdt_is_open)) 
    89 +               return -EBUSY; 
    90 +       wdt_count=0; 
    91 +       return nonseekable_open(inode, file); 
     57+    if (test_and_set_bit(0, &wdt_is_open)) 
     58+       return -EBUSY; 
     59+    set_bit(1, &wdt_is_open); 
     60+    return nonseekable_open(inode, file); 
    9261+} 
    9362+ 
    94 +static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 
     63+static ssize_t wdt_write(struct file *file, const char __user * buf, size_t count, loff_t * ppos) 
    9564+{ 
    96 +       if (count) { /* something was written */ 
    97 +               wdt_merlot_refresh(); 
    98 +       } 
    99 +       return count; 
     65+    if (count)         /* something was written */ 
     66+       wdt_merlot_refresh(); 
     67+    return count; 
    10068+} 
    10169+ 
    10270+static int wdt_release(struct inode *inode, struct file *file) 
    10371+{ 
    104 +       clear_bit(0, &wdt_is_open); 
    105 +       return 0; 
     72+    clear_bit(0, &wdt_is_open); 
     73+    return 0; 
    10674+} 
    10775+ 
    10876+static struct file_operations wdt_fops = { 
    109 +       .owner          = THIS_MODULE, 
    110 +       .llseek         = no_llseek, 
    111 +       .write          = wdt_write, 
    112 +       .open           = wdt_open, 
    113 +       .release        = wdt_release, 
     77+    .owner = THIS_MODULE, 
     78+    .llseek = no_llseek, 
     79+    .write = wdt_write, 
     80+    .open = wdt_open, 
     81+    .release = wdt_release, 
    11482+}; 
    11583+ 
    11684+static struct miscdevice wdt_miscdev = { 
    117 +       .minor  = WATCHDOG_MINOR, 
    118 +       .name   = "watchdog", 
    119 +       .fops   = &wdt_fops, 
     85+    .minor = WATCHDOG_MINOR, 
     86+    .name = "watchdog", 
     87+    .fops = &wdt_fops, 
    12088+}; 
    12189+ 
    12290+static void __exit wdt_exit(void) 
    12391+{ 
    124 +       misc_deregister(&wdt_miscdev); 
     92+    misc_deregister(&wdt_miscdev); 
    12593+} 
    12694+ 
    12795+static int __init wdt_init(void) 
    12896+{ 
    129 +       int ret; 
    130 +       ret = misc_register(&wdt_miscdev); 
    131 +       if (ret) { 
    132 +               printk(KERN_ERR "wdt: cannot register miscdev on minor=%d (err=%d)\n", 
    133 +                       WATCHDOG_MINOR, ret); 
    134 +               misc_deregister(&wdt_miscdev); 
    135 +               goto out; 
    136 +       } 
    137 +       printk("wdt: registered with refresh\n"); 
    138 +       wdt_merlot_refresh(); 
    139 +       wdt_merlot_setup_timer(); 
    140 +out: 
    141 +       return ret; 
     97+    int ret; 
     98+    ret = misc_register(&wdt_miscdev); 
     99+    if (ret) { 
     100+       printk(KERN_ERR 
     101+              "wdt: cannot register miscdev on minor=%d (err=%d)\n", 
     102+              WATCHDOG_MINOR, ret); 
     103+       misc_deregister(&wdt_miscdev); 
     104+       goto out; 
     105+    } 
     106+    printk("wdt: registered with refresh\n"); 
     107+    wdt_merlot_refresh(); 
     108+    wdt_merlot_setup_timer(); 
     109+  out: 
     110+    return ret; 
    142111+} 
    143112+ 
Note: See TracChangeset for help on using the changeset viewer.