aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/watchdog
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-14 18:17:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-14 18:17:12 -0400
commit5d89d9f502f9c33ed0270d716f238429861e1942 (patch)
tree6a353640e6836ca465f2dcf00323a7f8a793ae59 /Documentation/watchdog
parent50cff89837a43a7c62ac080de9742a298d6418b3 (diff)
parentfecf861e765b2f9ce1a0487c3940afaed80ef7a8 (diff)
Merge tag 'linux-kselftest-4.9-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates from Shuah Khan: "This update consists of: - Fixes and improvements to existing tests - Moving code from Documentation to selftests, samples, and tools: * Moves dnotify_test, prctl, ptp, vDSO, ia64, watchdog, and networking tests from Documentation to selftests. * Moves mic/mpssd, misc-devices/mei, timers, watchdog, auxdisplay, and blackfin examples from Documentation to samples. * Moves accounting, laptops/dslm, and pcmcia/crc32hash tools from Documentation to tools. * Deletes BUILD_DOCSRC and its dependencies" * tag 'linux-kselftest-4.9-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (21 commits) selftests/futex: Check ANSI terminal color support Doc: update 00-INDEX files to reflect the runnable code move samples: move blackfin gptimers-example from Documentation tools: move pcmcia crc32hash tool from Documentation tools: move laptops dslm tool from Documentation tools: move accounting tool from Documentation samples: move auxdisplay example code from Documentation samples: move watchdog example code from Documentation samples: move timers example code from Documentation samples: move misc-devices/mei example code from Documentation samples: move mic/mpssd example code from Documentation selftests: Move networking/timestamping from Documentation selftests: move watchdog tests from Documentation/watchdog selftests: move ia64 tests from Documentation/ia64 selftests: move vDSO tests from Documentation/vDSO selftests: move ptp tests from Documentation/ptp selftests: move prctl tests from Documentation/prctl selftests: move dnotify_test from Documentation/filesystems selftests/timers: Add missing error code assignment before test selftests/zram: replace ZRAM_LZ4_COMPRESS ...
Diffstat (limited to 'Documentation/watchdog')
-rw-r--r--Documentation/watchdog/Makefile1
-rw-r--r--Documentation/watchdog/src/.gitignore2
-rw-r--r--Documentation/watchdog/src/Makefile5
-rw-r--r--Documentation/watchdog/src/watchdog-simple.c24
-rw-r--r--Documentation/watchdog/src/watchdog-test.c105
-rw-r--r--Documentation/watchdog/watchdog-api.txt2
-rw-r--r--Documentation/watchdog/wdt.txt2
7 files changed, 2 insertions, 139 deletions
diff --git a/Documentation/watchdog/Makefile b/Documentation/watchdog/Makefile
deleted file mode 100644
index 6018f45f2471..000000000000
--- a/Documentation/watchdog/Makefile
+++ /dev/null
@@ -1 +0,0 @@
1subdir-y := src
diff --git a/Documentation/watchdog/src/.gitignore b/Documentation/watchdog/src/.gitignore
deleted file mode 100644
index ac90997dba93..000000000000
--- a/Documentation/watchdog/src/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
1watchdog-simple
2watchdog-test
diff --git a/Documentation/watchdog/src/Makefile b/Documentation/watchdog/src/Makefile
deleted file mode 100644
index 4a892c304983..000000000000
--- a/Documentation/watchdog/src/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1# List of programs to build
2hostprogs-y := watchdog-simple watchdog-test
3
4# Tell kbuild to always build the programs
5always := $(hostprogs-y)
diff --git a/Documentation/watchdog/src/watchdog-simple.c b/Documentation/watchdog/src/watchdog-simple.c
deleted file mode 100644
index ba45803a2216..000000000000
--- a/Documentation/watchdog/src/watchdog-simple.c
+++ /dev/null
@@ -1,24 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <fcntl.h>
5
6int main(void)
7{
8 int fd = open("/dev/watchdog", O_WRONLY);
9 int ret = 0;
10 if (fd == -1) {
11 perror("watchdog");
12 exit(EXIT_FAILURE);
13 }
14 while (1) {
15 ret = write(fd, "\0", 1);
16 if (ret != 1) {
17 ret = -1;
18 break;
19 }
20 sleep(10);
21 }
22 close(fd);
23 return ret;
24}
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c
deleted file mode 100644
index 6983d05097e2..000000000000
--- a/Documentation/watchdog/src/watchdog-test.c
+++ /dev/null
@@ -1,105 +0,0 @@
1/*
2 * Watchdog Driver Test Program
3 */
4
5#include <errno.h>
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9#include <unistd.h>
10#include <fcntl.h>
11#include <signal.h>
12#include <sys/ioctl.h>
13#include <linux/types.h>
14#include <linux/watchdog.h>
15
16int fd;
17const char v = 'V';
18
19/*
20 * This function simply sends an IOCTL to the driver, which in turn ticks
21 * the PC Watchdog card to reset its internal timer so it doesn't trigger
22 * a computer reset.
23 */
24static void keep_alive(void)
25{
26 int dummy;
27
28 printf(".");
29 ioctl(fd, WDIOC_KEEPALIVE, &dummy);
30}
31
32/*
33 * The main program. Run the program with "-d" to disable the card,
34 * or "-e" to enable the card.
35 */
36
37static void term(int sig)
38{
39 int ret = write(fd, &v, 1);
40
41 close(fd);
42 if (ret < 0)
43 printf("\nStopping watchdog ticks failed (%d)...\n", errno);
44 else
45 printf("\nStopping watchdog ticks...\n");
46 exit(0);
47}
48
49int main(int argc, char *argv[])
50{
51 int flags;
52 unsigned int ping_rate = 1;
53 int ret;
54
55 setbuf(stdout, NULL);
56
57 fd = open("/dev/watchdog", O_WRONLY);
58
59 if (fd == -1) {
60 printf("Watchdog device not enabled.\n");
61 exit(-1);
62 }
63
64 if (argc > 1) {
65 if (!strncasecmp(argv[1], "-d", 2)) {
66 flags = WDIOS_DISABLECARD;
67 ioctl(fd, WDIOC_SETOPTIONS, &flags);
68 printf("Watchdog card disabled.\n");
69 goto end;
70 } else if (!strncasecmp(argv[1], "-e", 2)) {
71 flags = WDIOS_ENABLECARD;
72 ioctl(fd, WDIOC_SETOPTIONS, &flags);
73 printf("Watchdog card enabled.\n");
74 goto end;
75 } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
76 flags = atoi(argv[2]);
77 ioctl(fd, WDIOC_SETTIMEOUT, &flags);
78 printf("Watchdog timeout set to %u seconds.\n", flags);
79 goto end;
80 } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
81 ping_rate = strtoul(argv[2], NULL, 0);
82 printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
83 } else {
84 printf("-d to disable, -e to enable, -t <n> to set " \
85 "the timeout,\n-p <n> to set the ping rate, and \n");
86 printf("run by itself to tick the card.\n");
87 goto end;
88 }
89 }
90
91 printf("Watchdog Ticking Away!\n");
92
93 signal(SIGINT, term);
94
95 while(1) {
96 keep_alive();
97 sleep(ping_rate);
98 }
99end:
100 ret = write(fd, &v, 1);
101 if (ret < 0)
102 printf("Stopping watchdog ticks failed (%d)...\n", errno);
103 close(fd);
104 return 0;
105}
diff --git a/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt
index b3a701f48118..0e62ba33b7fb 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -37,7 +37,7 @@ activates as soon as /dev/watchdog is opened and will reboot unless
37the watchdog is pinged within a certain time, this time is called the 37the watchdog is pinged within a certain time, this time is called the
38timeout or margin. The simplest way to ping the watchdog is to write 38timeout or margin. The simplest way to ping the watchdog is to write
39some data to the device. So a very simple watchdog daemon would look 39some data to the device. So a very simple watchdog daemon would look
40like this source file: see Documentation/watchdog/src/watchdog-simple.c 40like this source file: see samples/watchdog/watchdog-simple.c
41 41
42A more advanced driver could for example check that a HTTP server is 42A more advanced driver could for example check that a HTTP server is
43still responding before doing the write call to ping the watchdog. 43still responding before doing the write call to ping the watchdog.
diff --git a/Documentation/watchdog/wdt.txt b/Documentation/watchdog/wdt.txt
index 061c2e35384f..ed2f0b860869 100644
--- a/Documentation/watchdog/wdt.txt
+++ b/Documentation/watchdog/wdt.txt
@@ -47,4 +47,4 @@ The external event interfaces on the WDT boards are not currently supported.
47Minor numbers are however allocated for it. 47Minor numbers are however allocated for it.
48 48
49 49
50Example Watchdog Driver: see Documentation/watchdog/src/watchdog-simple.c 50Example Watchdog Driver: see samples/watchdog/watchdog-simple.c