drivers: watchdog: support setup watchdog timeout when close enable watchdog

Changelog: 看门狗驱动支持在关机调用看门狗时设置超时时间
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
tao89959
2026-08-24 14:17:17 +08:00
committed by maoxiaochuan
parent 45ccfb6664
commit 8604389b03
2 changed files with 13 additions and 0 deletions
+9
View File
@@ -47,6 +47,15 @@ config WATCHDOG_NOWAYOUT
get killed. If you say Y here, the watchdog cannot be stopped once
it has been started.
config WATCHDOG_TIMEOUT_ON_CLOSE
int "Timeout value for opening watchdog device"
default 5
depends on !WATCHDOG_NOWAYOUT
help
if not WATCHDOG_NOWAYOUT, mean setup watchdog daemon when poweroff
so this option is second about watchdog timeout.
if setup <= 0 mean not setup watchdog timeout. but ping watchdog also will exec
config WATCHDOG_HANDLE_BOOT_ENABLED
bool "Update boot-enabled watchdog until userspace takes over"
default y
+4
View File
@@ -966,6 +966,10 @@ static int watchdog_release(struct inode *inode, struct file *file)
/* If the watchdog was not stopped, send a keepalive ping */
if (err < 0) {
pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id);
#ifdef CONFIG_WATCHDOG_TIMEOUT_ON_CLOSE
if (wdd->ops->set_timeout && CONFIG_WATCHDOG_TIMEOUT_ON_CLOSE > 0)
wdd->ops->set_timeout(wdd, CONFIG_WATCHDOG_TIMEOUT_ON_CLOSE);
#endif
watchdog_ping(wdd);
}