watchdog_pretimeout.h 1.6 KB

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