watchdog_pretimeout.h 1.6 KB

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