diff options
Diffstat (limited to 'include/linux/watchdog.h')
-rw-r--r-- | include/linux/watchdog.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 7047bc7f8106..35a4d8185b51 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
@@ -19,6 +19,7 @@ | |||
19 | struct watchdog_ops; | 19 | struct watchdog_ops; |
20 | struct watchdog_device; | 20 | struct watchdog_device; |
21 | struct watchdog_core_data; | 21 | struct watchdog_core_data; |
22 | struct watchdog_governor; | ||
22 | 23 | ||
23 | /** struct watchdog_ops - The watchdog-devices operations | 24 | /** struct watchdog_ops - The watchdog-devices operations |
24 | * | 25 | * |
@@ -28,6 +29,7 @@ struct watchdog_core_data; | |||
28 | * @ping: The routine that sends a keepalive ping to the watchdog device. | 29 | * @ping: The routine that sends a keepalive ping to the watchdog device. |
29 | * @status: The routine that shows the status of the watchdog device. | 30 | * @status: The routine that shows the status of the watchdog device. |
30 | * @set_timeout:The routine for setting the watchdog devices timeout value (in seconds). | 31 | * @set_timeout:The routine for setting the watchdog devices timeout value (in seconds). |
32 | * @set_pretimeout:The routine for setting the watchdog devices pretimeout. | ||
31 | * @get_timeleft:The routine that gets the time left before a reset (in seconds). | 33 | * @get_timeleft:The routine that gets the time left before a reset (in seconds). |
32 | * @restart: The routine for restarting the machine. | 34 | * @restart: The routine for restarting the machine. |
33 | * @ioctl: The routines that handles extra ioctl calls. | 35 | * @ioctl: The routines that handles extra ioctl calls. |
@@ -46,6 +48,7 @@ struct watchdog_ops { | |||
46 | int (*ping)(struct watchdog_device *); | 48 | int (*ping)(struct watchdog_device *); |
47 | unsigned int (*status)(struct watchdog_device *); | 49 | unsigned int (*status)(struct watchdog_device *); |
48 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 50 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
51 | int (*set_pretimeout)(struct watchdog_device *, unsigned int); | ||
49 | unsigned int (*get_timeleft)(struct watchdog_device *); | 52 | unsigned int (*get_timeleft)(struct watchdog_device *); |
50 | int (*restart)(struct watchdog_device *, unsigned long, void *); | 53 | int (*restart)(struct watchdog_device *, unsigned long, void *); |
51 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | 54 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); |
@@ -59,8 +62,10 @@ struct watchdog_ops { | |||
59 | * watchdog device. | 62 | * watchdog device. |
60 | * @info: Pointer to a watchdog_info structure. | 63 | * @info: Pointer to a watchdog_info structure. |
61 | * @ops: Pointer to the list of watchdog operations. | 64 | * @ops: Pointer to the list of watchdog operations. |
65 | * @gov: Pointer to watchdog pretimeout governor. | ||
62 | * @bootstatus: Status of the watchdog device at boot. | 66 | * @bootstatus: Status of the watchdog device at boot. |
63 | * @timeout: The watchdog devices timeout value (in seconds). | 67 | * @timeout: The watchdog devices timeout value (in seconds). |
68 | * @pretimeout: The watchdog devices pre_timeout value. | ||
64 | * @min_timeout:The watchdog devices minimum timeout value (in seconds). | 69 | * @min_timeout:The watchdog devices minimum timeout value (in seconds). |
65 | * @max_timeout:The watchdog devices maximum timeout value (in seconds) | 70 | * @max_timeout:The watchdog devices maximum timeout value (in seconds) |
66 | * as configurable from user space. Only relevant if | 71 | * as configurable from user space. Only relevant if |
@@ -94,8 +99,10 @@ struct watchdog_device { | |||
94 | const struct attribute_group **groups; | 99 | const struct attribute_group **groups; |
95 | const struct watchdog_info *info; | 100 | const struct watchdog_info *info; |
96 | const struct watchdog_ops *ops; | 101 | const struct watchdog_ops *ops; |
102 | const struct watchdog_governor *gov; | ||
97 | unsigned int bootstatus; | 103 | unsigned int bootstatus; |
98 | unsigned int timeout; | 104 | unsigned int timeout; |
105 | unsigned int pretimeout; | ||
99 | unsigned int min_timeout; | 106 | unsigned int min_timeout; |
100 | unsigned int max_timeout; | 107 | unsigned int max_timeout; |
101 | unsigned int min_hw_heartbeat_ms; | 108 | unsigned int min_hw_heartbeat_ms; |
@@ -163,6 +170,13 @@ static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigne | |||
163 | t > wdd->max_timeout); | 170 | t > wdd->max_timeout); |
164 | } | 171 | } |
165 | 172 | ||
173 | /* Use the following function to check if a pretimeout value is invalid */ | ||
174 | static inline bool watchdog_pretimeout_invalid(struct watchdog_device *wdd, | ||
175 | unsigned int t) | ||
176 | { | ||
177 | return t && wdd->timeout && t >= wdd->timeout; | ||
178 | } | ||
179 | |||
166 | /* Use the following functions to manipulate watchdog driver specific data */ | 180 | /* Use the following functions to manipulate watchdog driver specific data */ |
167 | static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data) | 181 | static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data) |
168 | { | 182 | { |
@@ -174,6 +188,16 @@ static inline void *watchdog_get_drvdata(struct watchdog_device *wdd) | |||
174 | return wdd->driver_data; | 188 | return wdd->driver_data; |
175 | } | 189 | } |
176 | 190 | ||
191 | /* Use the following functions to report watchdog pretimeout event */ | ||
192 | #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV) | ||
193 | void watchdog_notify_pretimeout(struct watchdog_device *wdd); | ||
194 | #else | ||
195 | static inline void watchdog_notify_pretimeout(struct watchdog_device *wdd) | ||
196 | { | ||
197 | pr_alert("watchdog%d: pretimeout event\n", wdd->id); | ||
198 | } | ||
199 | #endif | ||
200 | |||
177 | /* drivers/watchdog/watchdog_core.c */ | 201 | /* drivers/watchdog/watchdog_core.c */ |
178 | void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority); | 202 | void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority); |
179 | extern int watchdog_init_timeout(struct watchdog_device *wdd, | 203 | extern int watchdog_init_timeout(struct watchdog_device *wdd, |