samples: move watchdog example code from Documentation
Move watchdog examples to samples and remove it from Documentation Makefile. Create a new Makefile to build watchdog. It can be built from top level directory or from watchdog directory: Run make -C samples/watchdog or cd samples/watchdog; make Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
This commit is contained in:
parent
155fe001c6
commit
071bf69a02
8 changed files with 11 additions and 9 deletions
|
|
@ -1,2 +1,2 @@
|
|||
subdir-y := accounting auxdisplay blackfin \
|
||||
laptops pcmcia watchdog
|
||||
laptops pcmcia
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
subdir-y := src
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# List of programs to build
|
||||
hostprogs-y := watchdog-simple
|
||||
|
||||
# Tell kbuild to always build the programs
|
||||
always := $(hostprogs-y)
|
||||
|
|
@ -37,7 +37,7 @@ activates as soon as /dev/watchdog is opened and will reboot unless
|
|||
the watchdog is pinged within a certain time, this time is called the
|
||||
timeout or margin. The simplest way to ping the watchdog is to write
|
||||
some data to the device. So a very simple watchdog daemon would look
|
||||
like this source file: see Documentation/watchdog/src/watchdog-simple.c
|
||||
like this source file: see samples/watchdog/watchdog-simple.c
|
||||
|
||||
A more advanced driver could for example check that a HTTP server is
|
||||
still responding before doing the write call to ping the watchdog.
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ The external event interfaces on the WDT boards are not currently supported.
|
|||
Minor numbers are however allocated for it.
|
||||
|
||||
|
||||
Example Watchdog Driver: see Documentation/watchdog/src/watchdog-simple.c
|
||||
Example Watchdog Driver: see samples/watchdog/watchdog-simple.c
|
||||
|
|
|
|||
1
samples/watchdog/.gitignore
vendored
Normal file
1
samples/watchdog/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
watchdog-simple
|
||||
8
samples/watchdog/Makefile
Normal file
8
samples/watchdog/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CC := $(CROSS_COMPILE)gcc
|
||||
PROGS := watchdog-simple
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
clean:
|
||||
rm -fr $(PROGS)
|
||||
|
||||
24
samples/watchdog/watchdog-simple.c
Normal file
24
samples/watchdog/watchdog-simple.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd = open("/dev/watchdog", O_WRONLY);
|
||||
int ret = 0;
|
||||
if (fd == -1) {
|
||||
perror("watchdog");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (1) {
|
||||
ret = write(fd, "\0", 1);
|
||||
if (ret != 1) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
sleep(10);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
Loading…
Reference in a new issue