// SPDX-License-Identifier: GPL-2.0+ /* * NS pc87413-wdt Watchdog Timer driver for Linux 2.6.x.x * * This code is based on wdt.c with original copyright. * * (C) Copyright 2006 Sven Anders, <anders@anduras.de> * and Marcus Junker, <junker@anduras.de> * * Neither Sven Anders, Marcus Junker nor ANDURAS AG * admit liability nor provide warranty for any of this software. * This material is provided "AS-IS" and at no charge. * * Release 1.1
*/
/** * pc87413_open: * @inode: inode of device * @file: file handle to device *
*/
staticint pc87413_open(struct inode *inode, struct file *file)
{ /* /dev/watchdog can only be opened once */
if (test_and_set_bit(0, &timer_enabled)) return -EBUSY;
if (nowayout)
__module_get(THIS_MODULE);
/* Reload and activate timer */
pc87413_refresh();
pr_info("Watchdog enabled. Timeout set to %d minute(s).\n", timeout);
return stream_open(inode, file);
}
/** * pc87413_release: * @inode: inode to board * @file: file handle to board * * The watchdog has a configurable API. There is a religious dispute * between people who want their watchdog to be able to shut down and * those who want to be sure if the watchdog manager dies the machine * reboots. In the former case we disable the counters, in the latter * case you have to open it again very soon.
*/
staticint pc87413_release(struct inode *inode, struct file *file)
{ /* Shut off the timer. */
/** * pc87413_status: * * return, if the watchdog is enabled (timeout is set...)
*/
staticint pc87413_status(void)
{ return 0; /* currently not supported */
}
/** * pc87413_write: * @file: file handle to the watchdog * @data: data buffer to write * @len: length in bytes * @ppos: pointer to the position to write. No seeks allowed * * A write to a watchdog device is defined as a keepalive signal. Any * write of data will do, as we we don't define content meaning.
*/
static ssize_t pc87413_write(struct file *file, constchar __user *data,
size_t len, loff_t *ppos)
{ /* See if we got the magic character 'V' and reload the timer */ if (len) { if (!nowayout) {
size_t i;
/* reset expect flag */
expect_close = 0;
/* scan to see whether or not we got the
magic character */ for (i = 0; i != len; i++) { char c; if (get_user(c, data + i)) return -EFAULT; if (c == 'V')
expect_close = 42;
}
}
/* someone wrote to us, we should reload the timer */
pc87413_refresh();
} return len;
}
/** * pc87413_ioctl: * @file: file handle to the device * @cmd: watchdog command * @arg: argument pointer * * The watchdog API defines a common set of functions for all watchdogs * according to their available features. We only actually usefully support * querying capabilities and current status.
*/
/** * pc87413_notify_sys: * @this: our notifier block * @code: the event being reported * @unused: unused * * Our notifier is called on system shutdowns. We want to turn the card * off at reboot otherwise the machine will reboot again during memory * test or worse yet during the following fsck. This would suck, in fact * trust me - if it happens it does suck.
*/
staticint pc87413_notify_sys(struct notifier_block *this, unsignedlong code, void *unused)
{ if (code == SYS_DOWN || code == SYS_HALT) /* Turn the card off */
pc87413_disable(); return NOTIFY_DONE;
}
/** * pc87413_init: module's "constructor" * * Set up the WDT watchdog board. All we have to do is grab the * resources we require and bitch if anyone beat us to them. * The open() function will actually kick the board off.
*/
staticint __init pc87413_init(void)
{ int ret;
pr_info("Version " VERSION " at io 0x%X\n",
WDT_INDEX_IO_PORT);
if (!request_muxed_region(io, 2, MODNAME)) return -EBUSY;
ret = register_reboot_notifier(&pc87413_notifier); if (ret != 0)
pr_err("cannot register reboot notifier (err=%d)\n", ret);
ret = misc_register(&pc87413_miscdev); if (ret != 0) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret); goto reboot_unreg;
}
pr_info("initialized. timeout=%d min\n", timeout);
/** * pc87413_exit: module's "destructor" * * Unload the watchdog. You cannot do this with any file handles open. * If your watchdog is set to continue ticking on close and you unload * it, well it keeps ticking. We won't get the interrupt but the board * will not touch PC memory so all is fine. You just have to load a new * module in 60 seconds or reboot.
*/
staticvoid __exit pc87413_exit(void)
{ /* Stop the timer before we leave */ if (!nowayout) {
pc87413_disable();
pr_info("Watchdog disabled\n");
}
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-04-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.