Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
debug.h
Go to the documentation of this file.
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 <[email protected]>
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 
25 #ifndef __DEBUG_H__
26 #define __DEBUG_H__
27 
28 #include <linux/bitops.h>
29 #include <linux/printk.h>
30 
31 #define DRIVER_NAME "wlcore"
32 #define DRIVER_PREFIX DRIVER_NAME ": "
33 
34 enum {
36  DEBUG_IRQ = BIT(0),
37  DEBUG_SPI = BIT(1),
42  DEBUG_TX = BIT(6),
43  DEBUG_RX = BIT(7),
46  DEBUG_PSM = BIT(10),
48  DEBUG_CMD = BIT(12),
49  DEBUG_ACX = BIT(13),
50  DEBUG_SDIO = BIT(14),
53  DEBUG_AP = BIT(17),
55  DEBUG_IO = BIT(19),
57  DEBUG_ALL = ~0,
58 };
59 
60 extern u32 wl12xx_debug_level;
61 
62 #define DEBUG_DUMP_LIMIT 1024
63 
64 #define wl1271_error(fmt, arg...) \
65  pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
66 
67 #define wl1271_warning(fmt, arg...) \
68  pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
69 
70 #define wl1271_notice(fmt, arg...) \
71  pr_info(DRIVER_PREFIX fmt "\n", ##arg)
72 
73 #define wl1271_info(fmt, arg...) \
74  pr_info(DRIVER_PREFIX fmt "\n", ##arg)
75 
76 /* define the debug macro differently if dynamic debug is supported */
77 #if defined(CONFIG_DYNAMIC_DEBUG)
78 #define wl1271_debug(level, fmt, arg...) \
79  do { \
80  if (unlikely(level & wl12xx_debug_level)) \
81  dynamic_pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \
82  } while (0)
83 #else
84 #define wl1271_debug(level, fmt, arg...) \
85  do { \
86  if (unlikely(level & wl12xx_debug_level)) \
87  printk(KERN_DEBUG pr_fmt(DRIVER_PREFIX fmt "\n"), \
88  ##arg); \
89  } while (0)
90 #endif
91 
92 /* TODO: use pr_debug_hex_dump when it becomes available */
93 #define wl1271_dump(level, prefix, buf, len) \
94  do { \
95  if (level & wl12xx_debug_level) \
96  print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
97  DUMP_PREFIX_OFFSET, 16, 1, \
98  buf, \
99  min_t(size_t, len, DEBUG_DUMP_LIMIT), \
100  0); \
101  } while (0)
102 
103 #define wl1271_dump_ascii(level, prefix, buf, len) \
104  do { \
105  if (level & wl12xx_debug_level) \
106  print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
107  DUMP_PREFIX_OFFSET, 16, 1, \
108  buf, \
109  min_t(size_t, len, DEBUG_DUMP_LIMIT), \
110  true); \
111  } while (0)
112 
113 #endif /* __DEBUG_H__ */