diff options
| author | Wim Van Sebroeck <wim@iguana.be> | 2011-07-22 14:55:18 -0400 |
|---|---|---|
| committer | Wim Van Sebroeck <wim@iguana.be> | 2011-07-28 04:01:04 -0400 |
| commit | 43316044d4f64da008d6aca7d4b60771b9a24eb8 (patch) | |
| tree | 66d0d023a8713119d973e3c367efa21fb5a1908f /include/linux | |
| parent | 5efc7a6222f6408d29d6beb1142a302f31dc9eac (diff) | |
watchdog: WatchDog Timer Driver Core - Add basic framework
The WatchDog Timer Driver Core is a framework
that contains the common code for all watchdog-driver's.
It also introduces a watchdog device structure and the
operations that go with it.
This is the introduction of this framework. This part
supports the minimal watchdog userspace API (or with
other words: the functionality to use /dev/watchdog's
open, release and write functionality as defined in
the simplest watchdog API). Extra functionality will
follow in the next set of patches.
Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/watchdog.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 011bcfeb9f09..5ab31bfd2906 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
| @@ -59,6 +59,67 @@ struct watchdog_info { | |||
| 59 | #define WATCHDOG_NOWAYOUT 0 | 59 | #define WATCHDOG_NOWAYOUT 0 |
| 60 | #endif | 60 | #endif |
| 61 | 61 | ||
| 62 | struct watchdog_ops; | ||
| 63 | struct watchdog_device; | ||
| 64 | |||
| 65 | /** struct watchdog_ops - The watchdog-devices operations | ||
| 66 | * | ||
| 67 | * @owner: The module owner. | ||
| 68 | * @start: The routine for starting the watchdog device. | ||
| 69 | * @stop: The routine for stopping the watchdog device. | ||
| 70 | * @ping: The routine that sends a keepalive ping to the watchdog device. | ||
| 71 | * | ||
| 72 | * The watchdog_ops structure contains a list of low-level operations | ||
| 73 | * that control a watchdog device. It also contains the module that owns | ||
| 74 | * these operations. The start and stop function are mandatory, all other | ||
| 75 | * functions are optonal. | ||
| 76 | */ | ||
| 77 | struct watchdog_ops { | ||
| 78 | struct module *owner; | ||
| 79 | /* mandatory operations */ | ||
| 80 | int (*start)(struct watchdog_device *); | ||
| 81 | int (*stop)(struct watchdog_device *); | ||
| 82 | /* optional operations */ | ||
| 83 | int (*ping)(struct watchdog_device *); | ||
| 84 | }; | ||
| 85 | |||
| 86 | /** struct watchdog_device - The structure that defines a watchdog device | ||
| 87 | * | ||
| 88 | * @info: Pointer to a watchdog_info structure. | ||
| 89 | * @ops: Pointer to the list of watchdog operations. | ||
| 90 | * @driver-data:Pointer to the drivers private data. | ||
| 91 | * @status: Field that contains the devices internal status bits. | ||
| 92 | * | ||
| 93 | * The watchdog_device structure contains all information about a | ||
| 94 | * watchdog timer device. | ||
| 95 | * | ||
| 96 | * The driver-data field may not be accessed directly. It must be accessed | ||
| 97 | * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. | ||
| 98 | */ | ||
| 99 | struct watchdog_device { | ||
| 100 | const struct watchdog_info *info; | ||
| 101 | const struct watchdog_ops *ops; | ||
| 102 | void *driver_data; | ||
| 103 | unsigned long status; | ||
| 104 | /* Bit numbers for status flags */ | ||
| 105 | #define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */ | ||
| 106 | }; | ||
| 107 | |||
| 108 | /* Use the following functions to manipulate watchdog driver specific data */ | ||
| 109 | static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data) | ||
| 110 | { | ||
| 111 | wdd->driver_data = data; | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline void *watchdog_get_drvdata(struct watchdog_device *wdd) | ||
| 115 | { | ||
| 116 | return wdd->driver_data; | ||
| 117 | } | ||
| 118 | |||
| 119 | /* drivers/watchdog/core/watchdog_core.c */ | ||
| 120 | extern int watchdog_register_device(struct watchdog_device *); | ||
| 121 | extern void watchdog_unregister_device(struct watchdog_device *); | ||
| 122 | |||
| 62 | #endif /* __KERNEL__ */ | 123 | #endif /* __KERNEL__ */ |
| 63 | 124 | ||
| 64 | #endif /* ifndef _LINUX_WATCHDOG_H */ | 125 | #endif /* ifndef _LINUX_WATCHDOG_H */ |
