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