mmrm_vm_debug.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __MMRM_VM_DEBUG__
  6. #define __MMRM_VM_DEBUG__
  7. #include <linux/debugfs.h>
  8. #include <linux/printk.h>
  9. #ifndef MMRM_VM_DBG_LABEL
  10. #define MMRM_VM_DBG_LABEL "mmrm_vm"
  11. #endif
  12. #define MMRM_VM_DBG_TAG MMRM_VM_DBG_LABEL ": %4s: "
  13. /* To enable messages OR these values and
  14. * echo the result to debugfs file.
  15. */
  16. enum mmrm_msg_prio {
  17. MMRM_VM_ERR = 0x000001,
  18. MMRM_VM_HIGH = 0x000002,
  19. MMRM_VM_LOW = 0x000004,
  20. MMRM_VM_WARN = 0x000008,
  21. MMRM_VM_PRINTK = 0x010000,
  22. };
  23. extern int mmrm_vm_debug;
  24. #define dprintk(__level, __fmt, ...) \
  25. do { \
  26. if (mmrm_vm_debug & __level) { \
  27. if (mmrm_vm_debug & MMRM_VM_PRINTK) { \
  28. pr_info(MMRM_VM_DBG_TAG __fmt, \
  29. get_debug_level_str(__level), \
  30. ##__VA_ARGS__); \
  31. } \
  32. } \
  33. } while (0)
  34. #define d_mpr_e(__fmt, ...) dprintk(MMRM_VM_ERR, __fmt, ##__VA_ARGS__)
  35. #define d_mpr_h(__fmt, ...) dprintk(MMRM_VM_HIGH, __fmt, ##__VA_ARGS__)
  36. #define d_mpr_l(__fmt, ...) dprintk(MMRM_VM_LOW, __fmt, ##__VA_ARGS__)
  37. #define d_mpr_w(__fmt, ...) dprintk(MMRM_VM_WARN, __fmt, ##__VA_ARGS__)
  38. static inline char *get_debug_level_str(int level)
  39. {
  40. switch (level) {
  41. case MMRM_VM_ERR:
  42. return "err ";
  43. case MMRM_VM_HIGH:
  44. return "high";
  45. case MMRM_VM_LOW:
  46. return "low ";
  47. case MMRM_VM_WARN:
  48. return "warn";
  49. default:
  50. return "????";
  51. }
  52. }
  53. #endif /* __MMRM_VM_DEBUG__ */