0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include <linux/hrtimer.h>
0028 #include <linux/kthread.h>
0029
0030 #define MAX_DOGS 32
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 struct watchdog_core_data {
0041 struct device dev;
0042 struct cdev cdev;
0043 struct watchdog_device *wdd;
0044 struct mutex lock;
0045 ktime_t last_keepalive;
0046 ktime_t last_hw_keepalive;
0047 ktime_t open_deadline;
0048 struct hrtimer timer;
0049 struct kthread_work work;
0050 #if IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT)
0051 struct hrtimer pretimeout_timer;
0052 #endif
0053 unsigned long status;
0054 #define _WDOG_DEV_OPEN 0
0055 #define _WDOG_ALLOW_RELEASE 1
0056 #define _WDOG_KEEPALIVE 2
0057 };
0058
0059
0060
0061
0062 extern int watchdog_dev_register(struct watchdog_device *);
0063 extern void watchdog_dev_unregister(struct watchdog_device *);
0064 extern int __init watchdog_dev_init(void);
0065 extern void __exit watchdog_dev_exit(void);
0066
0067 static inline bool watchdog_have_pretimeout(struct watchdog_device *wdd)
0068 {
0069 return wdd->info->options & WDIOF_PRETIMEOUT ||
0070 IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT);
0071 }
0072
0073 #if IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT)
0074 void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd);
0075 void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd);
0076 void watchdog_hrtimer_pretimeout_stop(struct watchdog_device *wdd);
0077 #else
0078 static inline void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd) {}
0079 static inline void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd) {}
0080 static inline void watchdog_hrtimer_pretimeout_stop(struct watchdog_device *wdd) {}
0081 #endif