debug.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // SPDX-License-Identifier: BSD-3-Clause-Clear
  2. /*
  3. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/vmalloc.h>
  6. #include "core.h"
  7. #include "debug.h"
  8. void ath11k_info(struct ath11k_base *ab, const char *fmt, ...)
  9. {
  10. struct va_format vaf = {
  11. .fmt = fmt,
  12. };
  13. va_list args;
  14. va_start(args, fmt);
  15. vaf.va = &args;
  16. dev_info(ab->dev, "%pV", &vaf);
  17. trace_ath11k_log_info(ab, &vaf);
  18. va_end(args);
  19. }
  20. EXPORT_SYMBOL(ath11k_info);
  21. void ath11k_err(struct ath11k_base *ab, const char *fmt, ...)
  22. {
  23. struct va_format vaf = {
  24. .fmt = fmt,
  25. };
  26. va_list args;
  27. va_start(args, fmt);
  28. vaf.va = &args;
  29. dev_err(ab->dev, "%pV", &vaf);
  30. trace_ath11k_log_err(ab, &vaf);
  31. va_end(args);
  32. }
  33. EXPORT_SYMBOL(ath11k_err);
  34. void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...)
  35. {
  36. struct va_format vaf = {
  37. .fmt = fmt,
  38. };
  39. va_list args;
  40. va_start(args, fmt);
  41. vaf.va = &args;
  42. dev_warn_ratelimited(ab->dev, "%pV", &vaf);
  43. trace_ath11k_log_warn(ab, &vaf);
  44. va_end(args);
  45. }
  46. EXPORT_SYMBOL(ath11k_warn);
  47. #ifdef CONFIG_ATH11K_DEBUG
  48. void __ath11k_dbg(struct ath11k_base *ab, enum ath11k_debug_mask mask,
  49. const char *fmt, ...)
  50. {
  51. struct va_format vaf;
  52. va_list args;
  53. va_start(args, fmt);
  54. vaf.fmt = fmt;
  55. vaf.va = &args;
  56. if (ath11k_debug_mask & mask)
  57. dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
  58. trace_ath11k_log_dbg(ab, mask, &vaf);
  59. va_end(args);
  60. }
  61. EXPORT_SYMBOL(__ath11k_dbg);
  62. void ath11k_dbg_dump(struct ath11k_base *ab,
  63. enum ath11k_debug_mask mask,
  64. const char *msg, const char *prefix,
  65. const void *buf, size_t len)
  66. {
  67. char linebuf[256];
  68. size_t linebuflen;
  69. const void *ptr;
  70. if (ath11k_debug_mask & mask) {
  71. if (msg)
  72. __ath11k_dbg(ab, mask, "%s\n", msg);
  73. for (ptr = buf; (ptr - buf) < len; ptr += 16) {
  74. linebuflen = 0;
  75. linebuflen += scnprintf(linebuf + linebuflen,
  76. sizeof(linebuf) - linebuflen,
  77. "%s%08x: ",
  78. (prefix ? prefix : ""),
  79. (unsigned int)(ptr - buf));
  80. hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1,
  81. linebuf + linebuflen,
  82. sizeof(linebuf) - linebuflen, true);
  83. dev_printk(KERN_DEBUG, ab->dev, "%s\n", linebuf);
  84. }
  85. }
  86. /* tracing code doesn't like null strings */
  87. trace_ath11k_log_dbg_dump(ab, msg ? msg : "", prefix ? prefix : "",
  88. buf, len);
  89. }
  90. EXPORT_SYMBOL(ath11k_dbg_dump);
  91. #endif /* CONFIG_ATH11K_DEBUG */