ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held
[linux/fpc-iii.git] / drivers / misc / iwmc3200top / log.h
blob4434bb16cea70798d846eac4c0ebd41437361c06
1 /*
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
19 * 02110-1301, USA.
22 * Author Name: Maxim Grabarnik <maxim.grabarnink@intel.com>
23 * -
27 #ifndef __LOG_H__
28 #define __LOG_H__
31 /* log severity:
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) | \
48 BIT(LOG_SEV_INFO) | \
49 BIT(LOG_SEV_INFOEX))
51 #define LOG_SEV_FILTER_ALL \
52 (BIT(LOG_SEV_CRITICAL) | \
53 BIT(LOG_SEV_ERROR) | \
54 BIT(LOG_SEV_WARNING) | \
55 BIT(LOG_SEV_INFO) | \
56 BIT(LOG_SEV_INFOEX) | \
57 BIT(LOG_SEV_TRACE) | \
58 BIT(LOG_SEV_DUMP))
60 /* log source */
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
65 #define LOG_SRC_TST 4
66 #define LOG_SRC_IRQ 5
68 #define LOG_SRC_MAX 6
69 #define LOG_SRC_ALL 0xFF
71 /**
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) | \
78 BIT(LOG_SEV_WARNING))
79 #endif
81 #ifndef FW_LOG_SEV_FILTER_RUNTIME
82 #define FW_LOG_SEV_FILTER_RUNTIME LOG_SEV_FILTER_ALL
83 #endif
85 #ifdef CONFIG_IWMC3200TOP_DEBUG
86 /**
87 * Log macros
90 #define priv2dev(priv) (&(priv->func)->dev)
92 #define LOG_CRITICAL(priv, src, fmt, args...) \
93 do { \
94 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_CRITICAL)) \
95 dev_crit(priv2dev(priv), "%s %d: " fmt, \
96 __func__, __LINE__, ##args); \
97 } while (0)
99 #define LOG_ERROR(priv, src, fmt, args...) \
100 do { \
101 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_ERROR)) \
102 dev_err(priv2dev(priv), "%s %d: " fmt, \
103 __func__, __LINE__, ##args); \
104 } while (0)
106 #define LOG_WARNING(priv, src, fmt, args...) \
107 do { \
108 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_WARNING)) \
109 dev_warn(priv2dev(priv), "%s %d: " fmt, \
110 __func__, __LINE__, ##args); \
111 } while (0)
113 #define LOG_INFO(priv, src, fmt, args...) \
114 do { \
115 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_INFO)) \
116 dev_info(priv2dev(priv), "%s %d: " fmt, \
117 __func__, __LINE__, ##args); \
118 } while (0)
120 #define LOG_TRACE(priv, src, fmt, args...) \
121 do { \
122 if (iwmct_logdefs[LOG_SRC_ ## src] & BIT(LOG_SEV_TRACE)) \
123 dev_dbg(priv2dev(priv), "%s %d: " fmt, \
124 __func__, __LINE__, ##args); \
125 } while (0)
127 #define LOG_HEXDUMP(src, ptr, len) \
128 do { \
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); \
132 } while (0)
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);
152 #else
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,
162 u8 *buf, int len) {}
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__ */