blob: a3f1abc68839aa9002c52c280488c2fe08841379 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Vladimir Zapolskiyff841362016-10-07 15:39:54 +03002#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);
Vladimir Zapolskiy89873a712016-10-07 15:39:57 +030022int watchdog_pretimeout_available_governors_get(char *buf);
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030023int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf);
Vladimir Zapolskiy53f96ce2016-10-07 15:37:00 +030024int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
25 const char *buf);
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030026
Vladimir Zapolskiyf77710c2016-10-07 15:39:55 +030027#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
28#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "noop"
Vladimir Zapolskiyda0d12f2016-10-07 15:39:56 +030029#elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
30#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "panic"
Vladimir Zapolskiyf77710c2016-10-07 15:39:55 +030031#endif
32
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030033#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
Vladimir Zapolskiy89873a712016-10-07 15:39:57 +030043static inline int watchdog_pretimeout_available_governors_get(char *buf)
44{
45 return -EINVAL;
46}
47
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030048static inline int watchdog_pretimeout_governor_get(struct watchdog_device *wdd,
49 char *buf)
50{
51 return -EINVAL;
52}
Vladimir Zapolskiy53f96ce2016-10-07 15:37:00 +030053
54static inline int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
55 const char *buf)
56{
57 return -EINVAL;
58}
Vladimir Zapolskiyff841362016-10-07 15:39:54 +030059#endif
60
61#endif