1 Index: linux-2.6.38-rc6/drivers/cbus/retu-wdt.c
2 ===================================================================
3 --- linux-2.6.38-rc6.orig/drivers/cbus/retu-wdt.c 2011-03-02 16:08:59.022211654 +0100
4 +++ linux-2.6.38-rc6/drivers/cbus/retu-wdt.c 2011-03-02 16:29:43.215284501 +0100
5 @@ -58,13 +58,11 @@ struct retu_wdt_dev {
8 struct miscdevice retu_wdt_miscdev;
9 - struct timer_list ping_timer;
10 + struct delayed_work ping_work;
13 static struct retu_wdt_dev *retu_wdt;
15 -static void retu_wdt_set_ping_timer(unsigned long enable);
17 static int _retu_modify_counter(unsigned int new)
20 @@ -86,6 +84,31 @@ static int retu_modify_counter(unsigned
25 + * Since retu watchdog cannot be disabled in hardware, we must kick it
26 + * with a timer until userspace watchdog software takes over. Do this
27 + * unless /dev/watchdog is open or CONFIG_WATCHDOG_NOWAYOUT is set.
29 +static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev)
31 + _retu_modify_counter(RETU_WDT_MAX_TIMER);
32 + schedule_delayed_work(&wdev->ping_work,
33 + round_jiffies_relative(RETU_WDT_DEFAULT_TIMER * HZ));
36 +static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev)
38 + _retu_modify_counter(RETU_WDT_MAX_TIMER);
39 + cancel_delayed_work_sync(&wdev->ping_work);
42 +static void retu_wdt_ping_work(struct work_struct *work)
44 + struct retu_wdt_dev *wdev = container_of(to_delayed_work(work),
45 + struct retu_wdt_dev, ping_work);
46 + retu_wdt_ping_enable(wdev);
49 static ssize_t retu_wdt_period_show(struct device *dev,
50 struct device_attribute *attr, char *buf)
52 @@ -105,7 +128,7 @@ static ssize_t retu_wdt_period_store(str
55 #ifdef CONFIG_WATCHDOG_NOWAYOUT
56 - retu_wdt_set_ping_timer(0);
57 + retu_wdt_ping_disable(retu_wdt);
60 if (sscanf(buf, "%u", &new_period) != 1) {
61 @@ -136,30 +159,13 @@ static DEVICE_ATTR(period, S_IRUGO | S_I
62 retu_wdt_period_store);
63 static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL);
65 -/*----------------------------------------------------------------------------*/
68 - * Since retu watchdog cannot be disabled in hardware, we must kick it
69 - * with a timer until userspace watchdog software takes over. Do this
70 - * unless /dev/watchdog is open or CONFIG_WATCHDOG_NOWAYOUT is set.
72 -static void retu_wdt_set_ping_timer(unsigned long enable)
74 - _retu_modify_counter(RETU_WDT_MAX_TIMER);
76 - mod_timer(&retu_wdt->ping_timer,
77 - jiffies + RETU_WDT_DEFAULT_TIMER * HZ);
79 - del_timer_sync(&retu_wdt->ping_timer);
82 static int retu_wdt_open(struct inode *inode, struct file *file)
84 if (test_and_set_bit(1, (unsigned long *)&(retu_wdt->users)))
87 file->private_data = (void *)retu_wdt;
88 - retu_wdt_set_ping_timer(0);
89 + retu_wdt_ping_disable(retu_wdt);
91 return nonseekable_open(inode, file);
93 @@ -169,7 +175,7 @@ static int retu_wdt_release(struct inode
94 struct retu_wdt_dev *wdev = file->private_data;
96 #ifndef CONFIG_WATCHDOG_NOWAYOUT
97 - retu_wdt_set_ping_timer(1);
98 + retu_wdt_ping_enable(retu_wdt);
102 @@ -232,7 +238,7 @@ static int __devinit retu_wdt_ping(void)
103 #ifdef CONFIG_WATCHDOG_NOWAYOUT
104 retu_modify_counter(RETU_WDT_MAX_TIMER);
106 - retu_wdt_set_ping_timer(1);
107 + retu_wdt_ping_enable(retu_wdt);
111 @@ -283,7 +289,7 @@ static int __init retu_wdt_probe(struct
115 - setup_timer(&wdev->ping_timer, retu_wdt_set_ping_timer, 1);
116 + INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work);
118 /* passed as module parameter? */
119 ret = retu_modify_counter(counter_param);
120 @@ -326,6 +332,7 @@ static int __devexit retu_wdt_remove(str
121 misc_deregister(&wdev->retu_wdt_miscdev);
122 device_remove_file(&pdev->dev, &dev_attr_period);
123 device_remove_file(&pdev->dev, &dev_attr_counter);
124 + cancel_delayed_work_sync(&wdev->ping_work);