26 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/kernel.h>
36 #include <linux/watchdog.h>
38 #include <linux/reboot.h>
44 #define WATCHDOG_VERSION "0.04"
45 #define WATCHDOG_NAME "Wdt977"
47 #define IO_INDEX_PORT 0x370
48 #define IO_DATA_PORT (IO_INDEX_PORT + 1)
50 #define UNLOCK_DATA 0x87
51 #define LOCK_DATA 0xAA
52 #define DEVICE_REGISTER 0x07
55 #define DEFAULT_TIMEOUT 60
59 static unsigned long timer_alive;
73 "Watchdog cannot be stopped once started (default="
80 static int wdt977_start(
void)
120 spin_unlock_irqrestore(&
spinlock, flags);
130 static int wdt977_stop(
void)
165 spin_unlock_irqrestore(&
spinlock, flags);
176 static int wdt977_keepalive(
void)
194 spin_unlock_irqrestore(&
spinlock, flags);
203 static int wdt977_set_timeout(
int t)
208 tmrval = (t + 59) / 60;
218 if (tmrval < 1 || tmrval > 255)
232 static int wdt977_get_status(
int *
status)
252 spin_unlock_irqrestore(&
spinlock, flags);
279 static int wdt977_release(
struct inode *inode,
struct file *file)
285 if (expect_close == 42) {
290 pr_crit(
"Unexpected close, not stopping watchdog!\n");
308 static ssize_t wdt977_write(
struct file *file,
const char __user *
buf,
309 size_t count, loff_t *ppos)
318 for (i = 0; i !=
count; i++) {
337 .firmware_version = 1,
352 static long wdt977_ioctl(
struct file *file,
unsigned int cmd,
363 uarg.i = (
int __user *)arg;
368 sizeof(ident)) ? -
EFAULT : 0;
371 wdt977_get_status(&status);
401 if (wdt977_set_timeout(new_timeout))
427 .write = wdt977_write,
428 .unlocked_ioctl = wdt977_ioctl,
430 .release = wdt977_release,
436 .fops = &wdt977_fops,
440 .notifier_call = wdt977_notify_sys,
443 static int __init wd977_init(
void)
451 if (wdt977_set_timeout(timeout)) {
453 pr_info(
"timeout value must be 60 < timeout < 15300, using %d\n",
462 pr_err(
"I/O address 0x%04x already in use\n",
471 pr_err(
"cannot register reboot notifier (err=%d)\n", rc);
477 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
478 wdt977_miscdev.
minor, rc);
482 pr_info(
"initialized. timeout=%d sec (nowayout=%d, testmode=%i)\n",
483 timeout, nowayout, testmode);
496 static void __exit wd977_exit(
void)