Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __WATCHDOG_PRETIMEOUT_H
0003 #define __WATCHDOG_PRETIMEOUT_H
0004 
0005 #define WATCHDOG_GOV_NAME_MAXLEN    20
0006 
0007 struct watchdog_device;
0008 
0009 struct watchdog_governor {
0010     const char  name[WATCHDOG_GOV_NAME_MAXLEN];
0011     void        (*pretimeout)(struct watchdog_device *wdd);
0012 };
0013 
0014 #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV)
0015 /* Interfaces to watchdog pretimeout governors */
0016 int watchdog_register_governor(struct watchdog_governor *gov);
0017 void watchdog_unregister_governor(struct watchdog_governor *gov);
0018 
0019 /* Interfaces to watchdog_dev.c */
0020 int watchdog_register_pretimeout(struct watchdog_device *wdd);
0021 void watchdog_unregister_pretimeout(struct watchdog_device *wdd);
0022 int watchdog_pretimeout_available_governors_get(char *buf);
0023 int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf);
0024 int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
0025                      const char *buf);
0026 
0027 #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
0028 #define WATCHDOG_PRETIMEOUT_DEFAULT_GOV     "noop"
0029 #elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
0030 #define WATCHDOG_PRETIMEOUT_DEFAULT_GOV     "panic"
0031 #endif
0032 
0033 #else
0034 static inline int watchdog_register_pretimeout(struct watchdog_device *wdd)
0035 {
0036     return 0;
0037 }
0038 
0039 static inline void watchdog_unregister_pretimeout(struct watchdog_device *wdd)
0040 {
0041 }
0042 
0043 static inline int watchdog_pretimeout_available_governors_get(char *buf)
0044 {
0045     return -EINVAL;
0046 }
0047 
0048 static inline int watchdog_pretimeout_governor_get(struct watchdog_device *wdd,
0049                            char *buf)
0050 {
0051     return -EINVAL;
0052 }
0053 
0054 static inline int watchdog_pretimeout_governor_set(struct watchdog_device *wdd,
0055                            const char *buf)
0056 {
0057     return -EINVAL;
0058 }
0059 #endif
0060 
0061 #endif