secdp_logger.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 and
  7. * only version 2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef _SECDP_LOGGER_H_
  16. #define _SECDP_LOGGER_H_
  17. #ifdef CONFIG_SECDP_LOGGER
  18. void secdp_logger_set_max_count(int count);
  19. void secdp_logger_print(const char *fmt, ...);
  20. void secdp_logger_hex_dump(void *buf, void *pref, size_t len);
  21. int secdp_logger_init(void);
  22. void secdp_logger_deinit(void);
  23. void secdp_logger_set_mode_max_count(unsigned int count);
  24. void secdp_logger_dec_mode_count(void);
  25. void secdp_logger_print_mode(const char *fmt, ...);
  26. #define secdp_pr_debug(fmt, ...) \
  27. printk(KERN_DEBUG "[msm-dp] %s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
  28. #define secdp_proc_err(fmt, ...) \
  29. do { \
  30. printk(KERN_ERR "[msm-dp] %s: " pr_fmt(fmt), __func__, ##__VA_ARGS__); \
  31. secdp_logger_print(fmt, ##__VA_ARGS__); \
  32. } while (0)
  33. #define secdp_proc_info(fmt, ...) \
  34. do { \
  35. printk(KERN_INFO "[msm-dp] %s: " pr_fmt(fmt), __func__, ##__VA_ARGS__); \
  36. secdp_logger_print(fmt, ##__VA_ARGS__); \
  37. } while (0)
  38. #define secdp_proc_warn(fmt, ...) \
  39. do { \
  40. printk(KERN_WARNING "[msm-dp] %s: " pr_fmt(fmt), __func__, ##__VA_ARGS__); \
  41. secdp_logger_print(fmt, ##__VA_ARGS__); \
  42. } while (0)
  43. #define secdp_proc_info_mode(fmt, ...) \
  44. do { \
  45. printk(KERN_INFO "[msm-dp] %s: " pr_fmt(fmt), __func__, ##__VA_ARGS__); \
  46. secdp_logger_print_mode(fmt, ##__VA_ARGS__); \
  47. } while (0)
  48. #define DP_INFO_M(fmt, ...) secdp_proc_info_mode(fmt, ##__VA_ARGS__)
  49. #ifdef pr_debug
  50. #undef pr_debug
  51. #define pr_debug secdp_pr_debug
  52. #endif
  53. #ifdef pr_err
  54. #undef pr_err
  55. #define pr_err secdp_proc_err
  56. #endif
  57. #ifdef pr_info
  58. #undef pr_info
  59. #define pr_info secdp_proc_info
  60. #endif
  61. #ifdef pr_warn
  62. #undef pr_warn
  63. #define pr_warn secdp_proc_warn
  64. #endif
  65. #else/* !CONFIG_SECDP_LOGGER */
  66. #define secdp_logger_set_max_count(x) do {} while (0)
  67. #define secdp_logger_print(fmt, ...) do {} while (0)
  68. #define secdp_logger_hex_dump(buf, pref, len) do {} while (0)
  69. #define secdp_logger_init(void) do {} while (0)
  70. #ifdef pr_debug
  71. #undef pr_debug
  72. #define pr_debug pr_info
  73. #endif
  74. #endif
  75. #endif/*_SECDP_LOGGER_H_*/