47 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
49 #include <linux/module.h>
53 #include <linux/reboot.h>
55 #include <linux/watchdog.h>
72 spin_lock(&sbwd_lock);
75 spin_unlock(&sbwd_lock);
86 spin_lock(&sbwd_lock);
88 spin_unlock(&sbwd_lock);
91 static unsigned long sbwdog_gate;
94 static unsigned long timeout = 0x7fffff
UL;
100 .identity =
"SiByte Watchdog",
125 static int sbwdog_release(
struct inode *inode,
struct file *file)
127 if (expect_close == 42) {
131 pr_crit(
"%s: Unexpected close, not stopping watchdog!\n",
144 static ssize_t sbwdog_write(
struct file *file,
const char __user *
data,
145 size_t len, loff_t *ppos)
155 for (i = 0; i != len; i++) {
169 static long sbwdog_ioctl(
struct file *file,
unsigned int cmd,
198 if (time > 0x7fffffUL) {
237 .write = sbwdog_write,
238 .unlocked_ioctl = sbwdog_ioctl,
240 .release = sbwdog_release,
246 .fops = &sbwdog_fops,
250 .notifier_call = sbwdog_notify_sys,
263 unsigned long wd_init;
264 char *wd_cfg_reg = (
char *)addr;
273 if (wd_cfg_reg == user_dog)
274 pr_crit(
"%s in danger of initiating system reset "
275 "in %ld.%01ld seconds\n",
277 wd_init / 1000000, (wd_init / 100000) % 10);
286 static int __init sbwdog_init(
void)
295 pr_err(
"%s: cannot register reboot notifier (err=%d)\n",
307 pr_err(
"%s: failed to request irq 1 - %d\n",
314 pr_info(
"%s: timeout is %ld.%ld secs\n",
316 timeout / 1000000, (timeout / 100000) % 10);
326 static void __exit sbwdog_exit(
void)
341 "Watchdog timeout in microseconds (max/default 8388607 or 8.3ish secs)");