iwl-debug.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  2. /*
  3. * Copyright (C) 2005-2011, 2021-2022 Intel Corporation
  4. */
  5. #include <linux/device.h>
  6. #include <linux/interrupt.h>
  7. #include <linux/export.h>
  8. #include "iwl-drv.h"
  9. #include "iwl-debug.h"
  10. #include "iwl-devtrace.h"
  11. #define __iwl_fn(fn) \
  12. void __iwl_ ##fn(struct device *dev, const char *fmt, ...) \
  13. { \
  14. struct va_format vaf = { \
  15. .fmt = fmt, \
  16. }; \
  17. va_list args; \
  18. \
  19. va_start(args, fmt); \
  20. vaf.va = &args; \
  21. dev_ ##fn(dev, "%pV", &vaf); \
  22. trace_iwlwifi_ ##fn(&vaf); \
  23. va_end(args); \
  24. }
  25. __iwl_fn(warn)
  26. IWL_EXPORT_SYMBOL(__iwl_warn);
  27. __iwl_fn(info)
  28. IWL_EXPORT_SYMBOL(__iwl_info);
  29. __iwl_fn(crit)
  30. IWL_EXPORT_SYMBOL(__iwl_crit);
  31. void __iwl_err(struct device *dev, enum iwl_err_mode mode, const char *fmt, ...)
  32. {
  33. struct va_format vaf = {
  34. .fmt = fmt,
  35. };
  36. va_list args, args2;
  37. va_start(args, fmt);
  38. switch (mode) {
  39. case IWL_ERR_MODE_RATELIMIT:
  40. if (net_ratelimit())
  41. break;
  42. fallthrough;
  43. case IWL_ERR_MODE_REGULAR:
  44. case IWL_ERR_MODE_RFKILL:
  45. va_copy(args2, args);
  46. vaf.va = &args2;
  47. if (mode == IWL_ERR_MODE_RFKILL)
  48. dev_err(dev, "(RFKILL) %pV", &vaf);
  49. else
  50. dev_err(dev, "%pV", &vaf);
  51. va_end(args2);
  52. break;
  53. default:
  54. break;
  55. }
  56. vaf.va = &args;
  57. trace_iwlwifi_err(&vaf);
  58. va_end(args);
  59. }
  60. IWL_EXPORT_SYMBOL(__iwl_err);
  61. #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
  62. void __iwl_dbg(struct device *dev,
  63. u32 level, bool limit, const char *function,
  64. const char *fmt, ...)
  65. {
  66. struct va_format vaf = {
  67. .fmt = fmt,
  68. };
  69. va_list args;
  70. va_start(args, fmt);
  71. vaf.va = &args;
  72. #ifdef CONFIG_IWLWIFI_DEBUG
  73. if (iwl_have_debug_level(level) &&
  74. (!limit || net_ratelimit()))
  75. dev_printk(KERN_DEBUG, dev, "%s %pV", function, &vaf);
  76. #endif
  77. trace_iwlwifi_dbg(level, function, &vaf);
  78. va_end(args);
  79. }
  80. IWL_EXPORT_SYMBOL(__iwl_dbg);
  81. #endif