debug.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * This file is part of wl12xx
  3. *
  4. * Copyright (C) 2011 Texas Instruments. All rights reserved.
  5. * Copyright (C) 2008-2009 Nokia Corporation
  6. *
  7. * Contact: Luciano Coelho <coelho@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef __DEBUG_H__
  25. #define __DEBUG_H__
  26. #include <linux/bitops.h>
  27. #include <linux/printk.h>
  28. #define DRIVER_NAME "wl12xx"
  29. #define DRIVER_PREFIX DRIVER_NAME ": "
  30. enum {
  31. DEBUG_NONE = 0,
  32. DEBUG_IRQ = BIT(0),
  33. DEBUG_SPI = BIT(1),
  34. DEBUG_BOOT = BIT(2),
  35. DEBUG_MAILBOX = BIT(3),
  36. DEBUG_TESTMODE = BIT(4),
  37. DEBUG_EVENT = BIT(5),
  38. DEBUG_TX = BIT(6),
  39. DEBUG_RX = BIT(7),
  40. DEBUG_SCAN = BIT(8),
  41. DEBUG_CRYPT = BIT(9),
  42. DEBUG_PSM = BIT(10),
  43. DEBUG_MAC80211 = BIT(11),
  44. DEBUG_CMD = BIT(12),
  45. DEBUG_ACX = BIT(13),
  46. DEBUG_SDIO = BIT(14),
  47. DEBUG_FILTERS = BIT(15),
  48. DEBUG_ADHOC = BIT(16),
  49. DEBUG_AP = BIT(17),
  50. DEBUG_PROBE = BIT(18),
  51. DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP),
  52. DEBUG_ALL = ~0,
  53. };
  54. extern u32 wl12xx_debug_level;
  55. #define DEBUG_DUMP_LIMIT 1024
  56. #define wl1271_error(fmt, arg...) \
  57. pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
  58. #define wl1271_warning(fmt, arg...) \
  59. pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
  60. #define wl1271_notice(fmt, arg...) \
  61. pr_info(DRIVER_PREFIX fmt "\n", ##arg)
  62. #define wl1271_info(fmt, arg...) \
  63. pr_info(DRIVER_PREFIX fmt "\n", ##arg)
  64. #define wl1271_debug(level, fmt, arg...) \
  65. do { \
  66. if (level & wl12xx_debug_level) \
  67. pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \
  68. } while (0)
  69. /* TODO: use pr_debug_hex_dump when it becomes available */
  70. #define wl1271_dump(level, prefix, buf, len) \
  71. do { \
  72. if (level & wl12xx_debug_level) \
  73. print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
  74. DUMP_PREFIX_OFFSET, 16, 1, \
  75. buf, \
  76. min_t(size_t, len, DEBUG_DUMP_LIMIT), \
  77. 0); \
  78. } while (0)
  79. #define wl1271_dump_ascii(level, prefix, buf, len) \
  80. do { \
  81. if (level & wl12xx_debug_level) \
  82. print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
  83. DUMP_PREFIX_OFFSET, 16, 1, \
  84. buf, \
  85. min_t(size_t, len, DEBUG_DUMP_LIMIT), \
  86. true); \
  87. } while (0)
  88. #endif /* __DEBUG_H__ */