2 * iwmc3200top - Intel Wireless MultiCom 3200 Top Driver
3 * drivers/misc/iwmc3200top/log.h
5 * Copyright (C) 2009 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * Author Name: Maxim Grabarnik <maxim.grabarnink@intel.com>
32 * The log levels here match FW log levels
33 * so values need to stay as is */
34 #define LOG_SEV_CRITICAL 0
35 #define LOG_SEV_ERROR 1
36 #define LOG_SEV_WARNING 2
37 #define LOG_SEV_INFO 3
38 #define LOG_SEV_INFOEX 4
40 /* Log levels not defined for FW */
41 #define LOG_SEV_TRACE 5
42 #define LOG_SEV_DUMP 6
44 #define LOG_SEV_FW_FILTER_ALL \
45 (BIT(LOG_SEV_CRITICAL) | \
46 BIT(LOG_SEV_ERROR) | \
47 BIT(LOG_SEV_WARNING) | \
51 #define LOG_SEV_FILTER_ALL \
52 (BIT(LOG_SEV_CRITICAL) | \
53 BIT(LOG_SEV_ERROR) | \
54 BIT(LOG_SEV_WARNING) | \
56 BIT(LOG_SEV_INFOEX) | \
57 BIT(LOG_SEV_TRACE) | \
61 #define LOG_SRC_INIT 0
62 #define LOG_SRC_DEBUGFS 1
63 #define LOG_SRC_FW_DOWNLOAD 2
64 #define LOG_SRC_FW_MSG 3
69 #define LOG_SRC_ALL 0xFF
72 * Default intitialization runtime log level
74 #ifndef LOG_SEV_FILTER_RUNTIME
75 #define LOG_SEV_FILTER_RUNTIME \
76 (BIT(LOG_SEV_CRITICAL) | \
77 BIT(LOG_SEV_ERROR) | \
81 #ifndef FW_LOG_SEV_FILTER_RUNTIME
82 #define FW_LOG_SEV_FILTER_RUNTIME LOG_SEV_FILTER_ALL
85 #ifdef CONFIG_IWMC3200TOP_DEBUG
90 #define priv2dev(priv) (&(priv->func)->dev)
92 #define LOG_CRITICAL(priv, src, fmt, args...) \
94 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_CRITICAL)) \
95 dev_crit(priv2dev(priv), "%s %d: " fmt, \
96 __func__, __LINE__, ##args); \
99 #define LOG_ERROR(priv, src, fmt, args...) \
101 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_ERROR)) \
102 dev_err(priv2dev(priv), "%s %d: " fmt, \
103 __func__, __LINE__, ##args); \
106 #define LOG_WARNING(priv, src, fmt, args...) \
108 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_WARNING)) \
109 dev_warn(priv2dev(priv), "%s %d: " fmt, \
110 __func__, __LINE__, ##args); \
113 #define LOG_INFO(priv, src, fmt, args...) \
115 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_INFO)) \
116 dev_info(priv2dev(priv), "%s %d: " fmt, \
117 __func__, __LINE__, ##args); \
120 #define LOG_TRACE(priv, src, fmt, args...) \
122 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_TRACE)) \
123 dev_dbg(priv2dev(priv), "%s %d: " fmt, \
124 __func__, __LINE__, ##args); \
127 #define LOG_HEXDUMP(src, ptr, len) \
129 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_DUMP)) \
130 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE, \
131 16, 1, ptr, len, false); \
134 void iwmct_log_top_message(struct iwmct_priv
*priv
, u8
*buf
, int len
);
136 extern u8 iwmct_logdefs
[];
138 int iwmct_log_set_filter(u8 src
, u8 logmask
);
139 int iwmct_log_set_fw_filter(u8 src
, u8 logmask
);
141 ssize_t
show_iwmct_log_level(struct device
*d
,
142 struct device_attribute
*attr
, char *buf
);
143 ssize_t
store_iwmct_log_level(struct device
*d
,
144 struct device_attribute
*attr
,
145 const char *buf
, size_t count
);
146 ssize_t
show_iwmct_log_level_fw(struct device
*d
,
147 struct device_attribute
*attr
, char *buf
);
148 ssize_t
store_iwmct_log_level_fw(struct device
*d
,
149 struct device_attribute
*attr
,
150 const char *buf
, size_t count
);
154 #define LOG_CRITICAL(priv, src, fmt, args...)
155 #define LOG_ERROR(priv, src, fmt, args...)
156 #define LOG_WARNING(priv, src, fmt, args...)
157 #define LOG_INFO(priv, src, fmt, args...)
158 #define LOG_TRACE(priv, src, fmt, args...)
159 #define LOG_HEXDUMP(src, ptr, len)
161 static inline void iwmct_log_top_message(struct iwmct_priv
*priv
,
163 static inline int iwmct_log_set_filter(u8 src
, u8 logmask
) { return 0; }
164 static inline int iwmct_log_set_fw_filter(u8 src
, u8 logmask
) { return 0; }
166 #endif /* CONFIG_IWMC3200TOP_DEBUG */
168 int log_get_filter_str(char *buf
, int size
);
169 int log_get_fw_filter_str(char *buf
, int size
);
171 #endif /* __LOG_H__ */