Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __WATCHDOG_PRETIMEOUT_H
3#define __WATCHDOG_PRETIMEOUT_H
4
5#define WATCHDOG_GOV_NAME_MAXLEN 20
6
7struct watchdog_device;
8
9struct watchdog_governor {
10 const char name[WATCHDOG_GOV_NAME_MAXLEN];
11 void (*pretimeout)(struct watchdog_device *wdd);
12};
13
14#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV)
15/* Interfaces to watchdog pretimeout governors */
16int watchdog_register_governor(struct watchdog_governor *gov);
17void watchdog_unregister_governor(struct watchdog_governor *gov);
18
19/* Interfaces to watchdog_dev.c */
20int watchdog_register_pretimeout(struct watchdog_device *wdd);
21void watchdog_unregister_pretimeout(struct watchdog_device *wdd);
22int watchdog_pretimeout_available_governors_get(char *buf);
23int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf);
24int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
25 const char *buf);
26
27#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
28#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "noop"
29#elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
30#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "panic"
31#endif
32
33#else
34static inline int watchdog_register_pretimeout(struct watchdog_device *wdd)
35{
36 return 0;
37}
38
39static inline void watchdog_unregister_pretimeout(struct watchdog_device *wdd)
40{
41}
42
43static inline int watchdog_pretimeout_available_governors_get(char *buf)
44{
45 return -EINVAL;
46}
47
48static inline int watchdog_pretimeout_governor_get(struct watchdog_device *wdd,
49 char *buf)
50{
51 return -EINVAL;
52}
53
54static inline int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
55 const char *buf)
56{
57 return -EINVAL;
58}
59#endif
60
61#endif
1#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_available_governors_get(char *buf);
22int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf);
23int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
24 const char *buf);
25
26#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
27#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "noop"
28#elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
29#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "panic"
30#endif
31
32#else
33static inline int watchdog_register_pretimeout(struct watchdog_device *wdd)
34{
35 return 0;
36}
37
38static inline void watchdog_unregister_pretimeout(struct watchdog_device *wdd)
39{
40}
41
42static inline int watchdog_pretimeout_available_governors_get(char *buf)
43{
44 return -EINVAL;
45}
46
47static inline int watchdog_pretimeout_governor_get(struct watchdog_device *wdd,
48 char *buf)
49{
50 return -EINVAL;
51}
52
53static inline int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
54 const char *buf)
55{
56 return -EINVAL;
57}
58#endif
59
60#endif