debug.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // SPDX-License-Identifier: BSD-3-Clause-Clear
  2. /*
  3. * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/vmalloc.h>
  7. #include "core.h"
  8. #include "debug.h"
  9. void ath12k_info(struct ath12k_base *ab, const char *fmt, ...)
  10. {
  11. struct va_format vaf = {
  12. .fmt = fmt,
  13. };
  14. va_list args;
  15. va_start(args, fmt);
  16. vaf.va = &args;
  17. dev_info(ab->dev, "%pV", &vaf);
  18. /* TODO: Trace the log */
  19. va_end(args);
  20. }
  21. void ath12k_err(struct ath12k_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. /* TODO: Trace the log */
  31. va_end(args);
  32. }
  33. void ath12k_warn(struct ath12k_base *ab, const char *fmt, ...)
  34. {
  35. struct va_format vaf = {
  36. .fmt = fmt,
  37. };
  38. va_list args;
  39. va_start(args, fmt);
  40. vaf.va = &args;
  41. dev_warn_ratelimited(ab->dev, "%pV", &vaf);
  42. /* TODO: Trace the log */
  43. va_end(args);
  44. }
  45. #ifdef CONFIG_ATH12K_DEBUG
  46. void __ath12k_dbg(struct ath12k_base *ab, enum ath12k_debug_mask mask,
  47. const char *fmt, ...)
  48. {
  49. struct va_format vaf;
  50. va_list args;
  51. va_start(args, fmt);
  52. vaf.fmt = fmt;
  53. vaf.va = &args;
  54. if (ath12k_debug_mask & mask)
  55. dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
  56. /* TODO: trace log */
  57. va_end(args);
  58. }
  59. void ath12k_dbg_dump(struct ath12k_base *ab,
  60. enum ath12k_debug_mask mask,
  61. const char *msg, const char *prefix,
  62. const void *buf, size_t len)
  63. {
  64. char linebuf[256];
  65. size_t linebuflen;
  66. const void *ptr;
  67. if (ath12k_debug_mask & mask) {
  68. if (msg)
  69. __ath12k_dbg(ab, mask, "%s\n", msg);
  70. for (ptr = buf; (ptr - buf) < len; ptr += 16) {
  71. linebuflen = 0;
  72. linebuflen += scnprintf(linebuf + linebuflen,
  73. sizeof(linebuf) - linebuflen,
  74. "%s%08x: ",
  75. (prefix ? prefix : ""),
  76. (unsigned int)(ptr - buf));
  77. hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1,
  78. linebuf + linebuflen,
  79. sizeof(linebuf) - linebuflen, true);
  80. dev_dbg(ab->dev, "%s\n", linebuf);
  81. }
  82. }
  83. }
  84. #endif /* CONFIG_ATH12K_DEBUG */