blob: 6cd6c89a411c926d30d378c25b9dddf0bd3719a6 [file] [log] [blame]
Vladimir Zapolskiyff841362016-10-07 15:39:54 +03001#ifndef __WATCHDOG_PRETIMEOUT_H
2#define __WATCHDOG_PRETIMEOUT_H
3
4#define WATCHDOG_GOV_NAME_MAXLEN 20
5
6struct watchdog_device;
7
8struct watchdog_governor {
9 const char name[WATCHDOG_GOV_NAME_MAXLEN];
10 void (*pretimeout)(struct watchdog_device *wdd);
11};
12
13#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV)
14/* Interfaces to watchdog pretimeout governors */
15int watchdog_register_governor(struct watchdog_governor *gov);
16void watchdog_unregister_governor(struct watchdog_governor *gov);
17
18/* Interfaces to watchdog_dev.c */
19int watchdog_register_pretimeout(struct watchdog_device *wdd);
20void watchdog_unregister_pretimeout(struct watchdog_device *wdd);
21int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf);
Vladimir Zapolskiy53f96ce2016-10-07 15:37:00 +030022int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
23 const char *buf);
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030024
Vladimir Zapolskiyf77710c2016-10-07 15:39:55 +030025#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
26#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "noop"
Vladimir Zapolskiyda0d12f2016-10-07 15:39:56 +030027#elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
28#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "panic"
Vladimir Zapolskiyf77710c2016-10-07 15:39:55 +030029#endif
30
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030031#else
32static inline int watchdog_register_pretimeout(struct watchdog_device *wdd)
33{
34 return 0;
35}
36
37static inline void watchdog_unregister_pretimeout(struct watchdog_device *wdd)
38{
39}
40
41static inline int watchdog_pretimeout_governor_get(struct watchdog_device *wdd,
42 char *buf)
43{
44 return -EINVAL;
45}
Vladimir Zapolskiy53f96ce2016-10-07 15:37:00 +030046
47static inline int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
48 const char *buf)
49{
50 return -EINVAL;
51}
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030052#endif
53
54#endif