x86/PCI: use host bridge _CRS info on ASUS M2V-MX SE
[linux-btrfs-devel.git] / Documentation / watchdog / src / watchdog-test.c
blob63fdc34ceb984733416d7113caf336cb9eb2556e
1 /*
2 * Watchdog Driver Test Program
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10 #include <sys/ioctl.h>
11 #include <linux/types.h>
12 #include <linux/watchdog.h>
14 int fd;
17 * This function simply sends an IOCTL to the driver, which in turn ticks
18 * the PC Watchdog card to reset its internal timer so it doesn't trigger
19 * a computer reset.
21 static void keep_alive(void)
23 int dummy;
25 ioctl(fd, WDIOC_KEEPALIVE, &dummy);
29 * The main program. Run the program with "-d" to disable the card,
30 * or "-e" to enable the card.
32 int main(int argc, char *argv[])
34 int flags;
36 fd = open("/dev/watchdog", O_WRONLY);
38 if (fd == -1) {
39 fprintf(stderr, "Watchdog device not enabled.\n");
40 fflush(stderr);
41 exit(-1);
44 if (argc > 1) {
45 if (!strncasecmp(argv[1], "-d", 2)) {
46 flags = WDIOS_DISABLECARD;
47 ioctl(fd, WDIOC_SETOPTIONS, &flags);
48 fprintf(stderr, "Watchdog card disabled.\n");
49 fflush(stderr);
50 exit(0);
51 } else if (!strncasecmp(argv[1], "-e", 2)) {
52 flags = WDIOS_ENABLECARD;
53 ioctl(fd, WDIOC_SETOPTIONS, &flags);
54 fprintf(stderr, "Watchdog card enabled.\n");
55 fflush(stderr);
56 exit(0);
57 } else {
58 fprintf(stderr, "-d to disable, -e to enable.\n");
59 fprintf(stderr, "run by itself to tick the card.\n");
60 fflush(stderr);
61 exit(0);
63 } else {
64 fprintf(stderr, "Watchdog Ticking Away!\n");
65 fflush(stderr);
68 while(1) {
69 keep_alive();
70 sleep(1);