1 --- a/drivers/watchdog/Kconfig
2 +++ b/drivers/watchdog/Kconfig
3 @@ -959,6 +959,7 @@ config ATH79_WDT
5 tristate "Broadcom BCM47xx Watchdog Timer"
9 Hardware driver for the Broadcom BCM47xx Watchdog Timer.
11 --- a/drivers/watchdog/bcm47xx_wdt.c
12 +++ b/drivers/watchdog/bcm47xx_wdt.c
15 #include <linux/bitops.h>
16 #include <linux/errno.h>
17 -#include <linux/fs.h>
18 #include <linux/init.h>
19 #include <linux/kernel.h>
20 -#include <linux/miscdevice.h>
21 #include <linux/module.h>
22 #include <linux/moduleparam.h>
23 #include <linux/reboot.h>
24 #include <linux/types.h>
25 -#include <linux/uaccess.h>
26 #include <linux/watchdog.h>
27 #include <linux/timer.h>
28 #include <linux/jiffies.h>
29 @@ -41,15 +38,11 @@ module_param(wdt_time, int, 0);
30 MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
31 __MODULE_STRING(WDT_DEFAULT_TIME) ")");
33 -#ifdef CONFIG_WATCHDOG_NOWAYOUT
34 module_param(nowayout, bool, 0);
35 MODULE_PARM_DESC(nowayout,
36 "Watchdog cannot be stopped once started (default="
37 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
40 -static unsigned long bcm47xx_wdt_busy;
41 -static char expect_release;
42 static struct timer_list wdt_timer;
43 static atomic_t ticks;
45 @@ -97,29 +90,31 @@ static void bcm47xx_timer_tick(unsigned
49 -static inline void bcm47xx_wdt_pet(void)
50 +static int bcm47xx_wdt_keepalive(struct watchdog_device *wdd)
52 atomic_set(&ticks, wdt_time);
57 -static void bcm47xx_wdt_start(void)
58 +static int bcm47xx_wdt_start(struct watchdog_device *wdd)
61 bcm47xx_timer_tick(0);
66 -static void bcm47xx_wdt_pause(void)
67 +static int bcm47xx_wdt_stop(struct watchdog_device *wdd)
69 del_timer_sync(&wdt_timer);
70 bcm47xx_wdt_hw_stop();
73 -static void bcm47xx_wdt_stop(void)
75 - bcm47xx_wdt_pause();
79 -static int bcm47xx_wdt_settimeout(int new_time)
80 +static int bcm47xx_wdt_set_timeout(struct watchdog_device *wdd,
81 + unsigned int new_time)
83 if ((new_time <= 0) || (new_time > WDT_MAX_TIME))
85 @@ -128,51 +123,6 @@ static int bcm47xx_wdt_settimeout(int ne
89 -static int bcm47xx_wdt_open(struct inode *inode, struct file *file)
91 - if (test_and_set_bit(0, &bcm47xx_wdt_busy))
94 - bcm47xx_wdt_start();
95 - return nonseekable_open(inode, file);
98 -static int bcm47xx_wdt_release(struct inode *inode, struct file *file)
100 - if (expect_release == 42) {
101 - bcm47xx_wdt_stop();
103 - pr_crit("Unexpected close, not stopping watchdog!\n");
104 - bcm47xx_wdt_start();
107 - clear_bit(0, &bcm47xx_wdt_busy);
108 - expect_release = 0;
112 -static ssize_t bcm47xx_wdt_write(struct file *file, const char __user *data,
113 - size_t len, loff_t *ppos)
119 - expect_release = 0;
121 - for (i = 0; i != len; i++) {
123 - if (get_user(c, data + i))
126 - expect_release = 42;
134 static const struct watchdog_info bcm47xx_wdt_info = {
135 .identity = DRV_NAME,
136 .options = WDIOF_SETTIMEOUT |
137 @@ -180,80 +130,25 @@ static const struct watchdog_info bcm47x
141 -static long bcm47xx_wdt_ioctl(struct file *file,
142 - unsigned int cmd, unsigned long arg)
144 - void __user *argp = (void __user *)arg;
145 - int __user *p = argp;
146 - int new_value, retval = -EINVAL;
149 - case WDIOC_GETSUPPORT:
150 - return copy_to_user(argp, &bcm47xx_wdt_info,
151 - sizeof(bcm47xx_wdt_info)) ? -EFAULT : 0;
153 - case WDIOC_GETSTATUS:
154 - case WDIOC_GETBOOTSTATUS:
155 - return put_user(0, p);
157 - case WDIOC_SETOPTIONS:
158 - if (get_user(new_value, p))
161 - if (new_value & WDIOS_DISABLECARD) {
162 - bcm47xx_wdt_stop();
166 - if (new_value & WDIOS_ENABLECARD) {
167 - bcm47xx_wdt_start();
173 - case WDIOC_KEEPALIVE:
177 - case WDIOC_SETTIMEOUT:
178 - if (get_user(new_value, p))
181 - if (bcm47xx_wdt_settimeout(new_value))
186 - case WDIOC_GETTIMEOUT:
187 - return put_user(wdt_time, p);
194 static int bcm47xx_wdt_notify_sys(struct notifier_block *this,
195 - unsigned long code, void *unused)
196 + unsigned long code, void *unused)
198 if (code == SYS_DOWN || code == SYS_HALT)
203 -static const struct file_operations bcm47xx_wdt_fops = {
204 +static struct watchdog_ops bcm47xx_wdt_ops = {
205 .owner = THIS_MODULE,
206 - .llseek = no_llseek,
207 - .unlocked_ioctl = bcm47xx_wdt_ioctl,
208 - .open = bcm47xx_wdt_open,
209 - .release = bcm47xx_wdt_release,
210 - .write = bcm47xx_wdt_write,
211 + .start = bcm47xx_wdt_start,
212 + .stop = bcm47xx_wdt_stop,
213 + .ping = bcm47xx_wdt_keepalive,
214 + .set_timeout = bcm47xx_wdt_set_timeout,
217 -static struct miscdevice bcm47xx_wdt_miscdev = {
218 - .minor = WATCHDOG_MINOR,
219 - .name = "watchdog",
220 - .fops = &bcm47xx_wdt_fops,
221 +static struct watchdog_device bcm47xx_wdt_wdd = {
222 + .info = &bcm47xx_wdt_info,
223 + .ops = &bcm47xx_wdt_ops,
226 static struct notifier_block bcm47xx_wdt_notifier = {
227 @@ -274,12 +169,13 @@ static int __init bcm47xx_wdt_init(void)
228 pr_info("wdt_time value must be 0 < wdt_time < %d, using %d\n",
229 (WDT_MAX_TIME + 1), wdt_time);
231 + watchdog_set_nowayout(&bcm47xx_wdt_wdd, nowayout);
233 ret = register_reboot_notifier(&bcm47xx_wdt_notifier);
237 - ret = misc_register(&bcm47xx_wdt_miscdev);
238 + ret = watchdog_register_device(&bcm47xx_wdt_wdd);
240 unregister_reboot_notifier(&bcm47xx_wdt_notifier);
242 @@ -292,10 +188,8 @@ static int __init bcm47xx_wdt_init(void)
244 static void __exit bcm47xx_wdt_exit(void)
247 - bcm47xx_wdt_stop();
249 - misc_deregister(&bcm47xx_wdt_miscdev);
250 + watchdog_stop(&bcm47xx_wdt_wdd);
251 + watchdog_unregister_device(&bcm47xx_wdt_wdd);
253 unregister_reboot_notifier(&bcm47xx_wdt_notifier);
255 @@ -306,4 +200,3 @@ module_exit(bcm47xx_wdt_exit);
256 MODULE_AUTHOR("Aleksandar Radovanovic");
257 MODULE_DESCRIPTION("Watchdog driver for Broadcom BCM47xx");
258 MODULE_LICENSE("GPL");
259 -MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);