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 #define LOG_SEV_FILTER_ALL \
41 (BIT(LOG_SEV_CRITICAL) | \
42 BIT(LOG_SEV_ERROR) | \
43 BIT(LOG_SEV_WARNING) | \
48 #define LOG_SRC_INIT 0
49 #define LOG_SRC_DEBUGFS 1
50 #define LOG_SRC_FW_DOWNLOAD 2
51 #define LOG_SRC_FW_MSG 3
56 #define LOG_SRC_ALL 0xFF
59 * Default intitialization runtime log level
61 #ifndef LOG_SEV_FILTER_RUNTIME
62 #define LOG_SEV_FILTER_RUNTIME \
63 (BIT(LOG_SEV_CRITICAL) | \
64 BIT(LOG_SEV_ERROR) | \
68 #ifndef FW_LOG_SEV_FILTER_RUNTIME
69 #define FW_LOG_SEV_FILTER_RUNTIME LOG_SEV_FILTER_ALL
72 #ifdef CONFIG_IWMC3200TOP_DEBUG
77 #define priv2dev(priv) (&(priv->func)->dev)
79 #define LOG_CRITICAL(priv, src, fmt, args...) \
81 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_CRITICAL)) \
82 dev_crit(priv2dev(priv), "%s %d: " fmt, \
83 __func__, __LINE__, ##args); \
86 #define LOG_ERROR(priv, src, fmt, args...) \
88 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_ERROR)) \
89 dev_err(priv2dev(priv), "%s %d: " fmt, \
90 __func__, __LINE__, ##args); \
93 #define LOG_WARNING(priv, src, fmt, args...) \
95 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_WARNING)) \
96 dev_warn(priv2dev(priv), "%s %d: " fmt, \
97 __func__, __LINE__, ##args); \
100 #define LOG_INFO(priv, src, fmt, args...) \
102 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_INFO)) \
103 dev_info(priv2dev(priv), "%s %d: " fmt, \
104 __func__, __LINE__, ##args); \
107 #define LOG_INFOEX(priv, src, fmt, args...) \
109 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_INFOEX)) \
110 dev_dbg(priv2dev(priv), "%s %d: " fmt, \
111 __func__, __LINE__, ##args); \
114 #define LOG_HEXDUMP(src, ptr, len) \
116 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_INFOEX)) \
117 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE, \
118 16, 1, ptr, len, false); \
121 void iwmct_log_top_message(struct iwmct_priv
*priv
, u8
*buf
, int len
);
123 extern u8 iwmct_logdefs
[];
125 int iwmct_log_set_filter(u8 src
, u8 logmask
);
126 int iwmct_log_set_fw_filter(u8 src
, u8 logmask
);
128 ssize_t
show_iwmct_log_level(struct device
*d
,
129 struct device_attribute
*attr
, char *buf
);
130 ssize_t
store_iwmct_log_level(struct device
*d
,
131 struct device_attribute
*attr
,
132 const char *buf
, size_t count
);
133 ssize_t
show_iwmct_log_level_fw(struct device
*d
,
134 struct device_attribute
*attr
, char *buf
);
135 ssize_t
store_iwmct_log_level_fw(struct device
*d
,
136 struct device_attribute
*attr
,
137 const char *buf
, size_t count
);
141 #define LOG_CRITICAL(priv, src, fmt, args...)
142 #define LOG_ERROR(priv, src, fmt, args...)
143 #define LOG_WARNING(priv, src, fmt, args...)
144 #define LOG_INFO(priv, src, fmt, args...)
145 #define LOG_INFOEX(priv, src, fmt, args...)
146 #define LOG_HEXDUMP(src, ptr, len)
148 static inline void iwmct_log_top_message(struct iwmct_priv
*priv
,
150 static inline int iwmct_log_set_filter(u8 src
, u8 logmask
) { return 0; }
151 static inline int iwmct_log_set_fw_filter(u8 src
, u8 logmask
) { return 0; }
153 #endif /* CONFIG_IWMC3200TOP_DEBUG */
155 int log_get_filter_str(char *buf
, int size
);
156 int log_get_fw_filter_str(char *buf
, int size
);
158 #endif /* __LOG_H__ */