aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>2016-10-07 08:39:55 -0400
committerWim Van Sebroeck <wim@iguana.be>2016-10-08 04:27:13 -0400
commitf77710c4cda01ad9c3672fb2f97bdea9a94da92a (patch)
tree95d9c0f16b6270d486f6b3873363799d46a45795 /drivers/watchdog
parentff84136cb6a4943f489ad037fe93f43be0573c23 (diff)
watchdog: pretimeout: add noop pretimeout governor
The change adds noop watchdog pretimeout governor, only an informational message is printed to the kernel log buffer when a watchdog triggers a pretimeout event. While introducing the first pretimeout governor the selected design assumes that the default pretimeout governor is selected by its name and it is always built-in, thus the default pretimeout governor can not be unregistered and the correspondent check can be removed from the watchdog_unregister_governor() function. Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/Kconfig28
-rw-r--r--drivers/watchdog/Makefile2
-rw-r--r--drivers/watchdog/pretimeout_noop.c47
-rw-r--r--drivers/watchdog/watchdog_pretimeout.h4
4 files changed, 81 insertions, 0 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 04d535ae497d..4aeb8f95beb4 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1838,4 +1838,32 @@ config WATCHDOG_PRETIMEOUT_GOV
1838 help 1838 help
1839 The option allows to select watchdog pretimeout governors. 1839 The option allows to select watchdog pretimeout governors.
1840 1840
1841if WATCHDOG_PRETIMEOUT_GOV
1842
1843choice
1844 prompt "Default Watchdog Pretimeout Governor"
1845 default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC
1846 help
1847 This option selects a default watchdog pretimeout governor.
1848 The governor takes its action, if a watchdog is capable
1849 to report a pretimeout event.
1850
1851config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP
1852 bool "noop"
1853 select WATCHDOG_PRETIMEOUT_GOV_NOOP
1854 help
1855 Use noop watchdog pretimeout governor by default. If noop
1856 governor is selected by a user, write a short message to
1857 the kernel log buffer and don't do any system changes.
1858
1859endchoice
1860
1861config WATCHDOG_PRETIMEOUT_GOV_NOOP
1862 tristate "Noop watchdog pretimeout governor"
1863 help
1864 Noop watchdog pretimeout governor, only an informational
1865 message is added to kernel log buffer.
1866
1867endif # WATCHDOG_PRETIMEOUT_GOV
1868
1841endif # WATCHDOG 1869endif # WATCHDOG
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 990c36ed4716..0502a21db1db 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -9,6 +9,8 @@ watchdog-objs += watchdog_core.o watchdog_dev.o
9 9
10watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o 10watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o
11 11
12obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP) += pretimeout_noop.o
13
12# Only one watchdog can succeed. We probe the ISA/PCI/USB based 14# Only one watchdog can succeed. We probe the ISA/PCI/USB based
13# watchdog-cards first, then the architecture specific watchdog 15# watchdog-cards first, then the architecture specific watchdog
14# drivers and then the architecture independent "softdog" driver. 16# drivers and then the architecture independent "softdog" driver.
diff --git a/drivers/watchdog/pretimeout_noop.c b/drivers/watchdog/pretimeout_noop.c
new file mode 100644
index 000000000000..85f5299d197c
--- /dev/null
+++ b/drivers/watchdog/pretimeout_noop.c
@@ -0,0 +1,47 @@
1/*
2 * Copyright (C) 2015-2016 Mentor Graphics
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 */
10
11#include <linux/module.h>
12#include <linux/printk.h>
13#include <linux/watchdog.h>
14
15#include "watchdog_pretimeout.h"
16
17/**
18 * pretimeout_noop - No operation on watchdog pretimeout event
19 * @wdd - watchdog_device
20 *
21 * This function prints a message about pretimeout to kernel log.
22 */
23static void pretimeout_noop(struct watchdog_device *wdd)
24{
25 pr_alert("watchdog%d: pretimeout event\n", wdd->id);
26}
27
28static struct watchdog_governor watchdog_gov_noop = {
29 .name = "noop",
30 .pretimeout = pretimeout_noop,
31};
32
33static int __init watchdog_gov_noop_register(void)
34{
35 return watchdog_register_governor(&watchdog_gov_noop);
36}
37
38static void __exit watchdog_gov_noop_unregister(void)
39{
40 watchdog_unregister_governor(&watchdog_gov_noop);
41}
42module_init(watchdog_gov_noop_register);
43module_exit(watchdog_gov_noop_unregister);
44
45MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>");
46MODULE_DESCRIPTION("Panic watchdog pretimeout governor");
47MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/watchdog_pretimeout.h b/drivers/watchdog/watchdog_pretimeout.h
index c6cd9f80adb2..c4b6f88dc9c9 100644
--- a/drivers/watchdog/watchdog_pretimeout.h
+++ b/drivers/watchdog/watchdog_pretimeout.h
@@ -20,6 +20,10 @@ int watchdog_register_pretimeout(struct watchdog_device *wdd);
20void watchdog_unregister_pretimeout(struct watchdog_device *wdd); 20void watchdog_unregister_pretimeout(struct watchdog_device *wdd);
21int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf); 21int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf);
22 22
23#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
24#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "noop"
25#endif
26
23#else 27#else
24static inline int watchdog_register_pretimeout(struct watchdog_device *wdd) 28static inline int watchdog_register_pretimeout(struct watchdog_device *wdd)
25{ 29{