Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 1 | #ifndef __KERNEL_PRINTK__ |
| 2 | #define __KERNEL_PRINTK__ |
| 3 | |
Mike Travis | 162a7e7 | 2011-05-24 17:13:20 -0700 | [diff] [blame] | 4 | #include <linux/init.h> |
Joe Perches | 314ba35 | 2012-07-30 14:40:11 -0700 | [diff] [blame] | 5 | #include <linux/kern_levels.h> |
Mike Travis | 162a7e7 | 2011-05-24 17:13:20 -0700 | [diff] [blame] | 6 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 7 | extern const char linux_banner[]; |
| 8 | extern const char linux_proc_banner[]; |
| 9 | |
Joe Perches | acc8fa41 | 2012-07-30 14:40:09 -0700 | [diff] [blame] | 10 | static inline int printk_get_level(const char *buffer) |
| 11 | { |
Joe Perches | 04d2c8c | 2012-07-30 14:40:17 -0700 | [diff] [blame] | 12 | if (buffer[0] == KERN_SOH_ASCII && buffer[1]) { |
Joe Perches | acc8fa41 | 2012-07-30 14:40:09 -0700 | [diff] [blame] | 13 | switch (buffer[1]) { |
| 14 | case '0' ... '7': |
| 15 | case 'd': /* KERN_DEFAULT */ |
Joe Perches | acc8fa41 | 2012-07-30 14:40:09 -0700 | [diff] [blame] | 16 | return buffer[1]; |
| 17 | } |
| 18 | } |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static inline const char *printk_skip_level(const char *buffer) |
| 23 | { |
| 24 | if (printk_get_level(buffer)) { |
| 25 | switch (buffer[1]) { |
| 26 | case '0' ... '7': |
| 27 | case 'd': /* KERN_DEFAULT */ |
Joe Perches | 04d2c8c | 2012-07-30 14:40:17 -0700 | [diff] [blame] | 28 | return buffer + 2; |
Joe Perches | acc8fa41 | 2012-07-30 14:40:09 -0700 | [diff] [blame] | 29 | } |
| 30 | } |
| 31 | return buffer; |
| 32 | } |
| 33 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 34 | extern int console_printk[]; |
| 35 | |
| 36 | #define console_loglevel (console_printk[0]) |
| 37 | #define default_message_loglevel (console_printk[1]) |
| 38 | #define minimum_console_loglevel (console_printk[2]) |
| 39 | #define default_console_loglevel (console_printk[3]) |
| 40 | |
Joe Perches | a9747cc | 2011-01-12 16:59:43 -0800 | [diff] [blame] | 41 | static inline void console_silent(void) |
| 42 | { |
| 43 | console_loglevel = 0; |
| 44 | } |
| 45 | |
| 46 | static inline void console_verbose(void) |
| 47 | { |
| 48 | if (console_loglevel) |
| 49 | console_loglevel = 15; |
| 50 | } |
| 51 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 52 | struct va_format { |
| 53 | const char *fmt; |
| 54 | va_list *va; |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | * FW_BUG |
| 59 | * Add this to a message where you are sure the firmware is buggy or behaves |
| 60 | * really stupid or out of spec. Be aware that the responsible BIOS developer |
| 61 | * should be able to fix this issue or at least get a concrete idea of the |
| 62 | * problem by reading your message without the need of looking at the kernel |
| 63 | * code. |
| 64 | * |
| 65 | * Use it for definite and high priority BIOS bugs. |
| 66 | * |
| 67 | * FW_WARN |
| 68 | * Use it for not that clear (e.g. could the kernel messed up things already?) |
| 69 | * and medium priority BIOS bugs. |
| 70 | * |
| 71 | * FW_INFO |
| 72 | * Use this one if you want to tell the user or vendor about something |
| 73 | * suspicious, but generally harmless related to the firmware. |
| 74 | * |
| 75 | * Use it for information or very low priority BIOS bugs. |
| 76 | */ |
| 77 | #define FW_BUG "[Firmware Bug]: " |
| 78 | #define FW_WARN "[Firmware Warn]: " |
| 79 | #define FW_INFO "[Firmware Info]: " |
| 80 | |
| 81 | /* |
| 82 | * HW_ERR |
| 83 | * Add this to a message for hardware errors, so that user can report |
| 84 | * it to hardware vendor instead of LKML or software vendor. |
| 85 | */ |
| 86 | #define HW_ERR "[Hardware Error]: " |
| 87 | |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 88 | /* |
| 89 | * Dummy printk for disabled debugging statements to use whilst maintaining |
| 90 | * gcc's format and side-effect checking. |
| 91 | */ |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 92 | static inline __printf(1, 2) |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 93 | int no_printk(const char *fmt, ...) |
| 94 | { |
| 95 | return 0; |
| 96 | } |
| 97 | |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame^] | 98 | #ifdef CONFIG_EARLY_PRINTK |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 99 | extern asmlinkage __printf(1, 2) |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 100 | void early_printk(const char *fmt, ...); |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame^] | 101 | void early_vprintk(const char *fmt, va_list ap); |
| 102 | #else |
| 103 | static inline __printf(1, 2) __cold |
| 104 | void early_printk(const char *s, ...) { } |
| 105 | #endif |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 106 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 107 | #ifdef CONFIG_PRINTK |
Kay Sievers | 7ff9554 | 2012-05-03 02:29:13 +0200 | [diff] [blame] | 108 | asmlinkage __printf(5, 0) |
| 109 | int vprintk_emit(int facility, int level, |
| 110 | const char *dict, size_t dictlen, |
| 111 | const char *fmt, va_list args); |
| 112 | |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 113 | asmlinkage __printf(1, 0) |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 114 | int vprintk(const char *fmt, va_list args); |
Kay Sievers | 7ff9554 | 2012-05-03 02:29:13 +0200 | [diff] [blame] | 115 | |
| 116 | asmlinkage __printf(5, 6) __cold |
| 117 | asmlinkage int printk_emit(int facility, int level, |
| 118 | const char *dict, size_t dictlen, |
| 119 | const char *fmt, ...); |
| 120 | |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 121 | asmlinkage __printf(1, 2) __cold |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 122 | int printk(const char *fmt, ...); |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 123 | |
| 124 | /* |
Peter Zijlstra | 3ccf3e8 | 2012-02-27 10:47:00 +0100 | [diff] [blame] | 125 | * Special printk facility for scheduler use only, _DO_NOT_USE_ ! |
| 126 | */ |
| 127 | __printf(1, 2) __cold int printk_sched(const char *fmt, ...); |
| 128 | |
| 129 | /* |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 130 | * Please don't use printk_ratelimit(), because it shares ratelimiting state |
| 131 | * with all other unrelated printk_ratelimit() callsites. Instead use |
| 132 | * printk_ratelimited() or plain old __ratelimit(). |
| 133 | */ |
| 134 | extern int __printk_ratelimit(const char *func); |
| 135 | #define printk_ratelimit() __printk_ratelimit(__func__) |
| 136 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
| 137 | unsigned int interval_msec); |
| 138 | |
| 139 | extern int printk_delay_msec; |
| 140 | extern int dmesg_restrict; |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 141 | extern int kptr_restrict; |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 142 | |
Frederic Weisbecker | dc72c32 | 2013-03-22 15:04:39 -0700 | [diff] [blame] | 143 | extern void wake_up_klogd(void); |
| 144 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 145 | void log_buf_kexec_setup(void); |
Mike Travis | 162a7e7 | 2011-05-24 17:13:20 -0700 | [diff] [blame] | 146 | void __init setup_log_buf(int early); |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 147 | #else |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 148 | static inline __printf(1, 0) |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 149 | int vprintk(const char *s, va_list args) |
| 150 | { |
| 151 | return 0; |
| 152 | } |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 153 | static inline __printf(1, 2) __cold |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 154 | int printk(const char *s, ...) |
| 155 | { |
| 156 | return 0; |
| 157 | } |
Peter Zijlstra | 3ccf3e8 | 2012-02-27 10:47:00 +0100 | [diff] [blame] | 158 | static inline __printf(1, 2) __cold |
| 159 | int printk_sched(const char *s, ...) |
| 160 | { |
| 161 | return 0; |
| 162 | } |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 163 | static inline int printk_ratelimit(void) |
| 164 | { |
| 165 | return 0; |
| 166 | } |
| 167 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
| 168 | unsigned int interval_msec) |
| 169 | { |
| 170 | return false; |
| 171 | } |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 172 | |
Frederic Weisbecker | dc72c32 | 2013-03-22 15:04:39 -0700 | [diff] [blame] | 173 | static inline void wake_up_klogd(void) |
| 174 | { |
| 175 | } |
| 176 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 177 | static inline void log_buf_kexec_setup(void) |
| 178 | { |
| 179 | } |
Mike Travis | 162a7e7 | 2011-05-24 17:13:20 -0700 | [diff] [blame] | 180 | |
| 181 | static inline void setup_log_buf(int early) |
| 182 | { |
| 183 | } |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 184 | #endif |
| 185 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 186 | extern void dump_stack(void) __cold; |
| 187 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 188 | #ifndef pr_fmt |
| 189 | #define pr_fmt(fmt) fmt |
| 190 | #endif |
| 191 | |
| 192 | #define pr_emerg(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 193 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 194 | #define pr_alert(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 195 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 196 | #define pr_crit(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 197 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 198 | #define pr_err(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 199 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 200 | #define pr_warning(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 201 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 202 | #define pr_warn pr_warning |
| 203 | #define pr_notice(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 204 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 205 | #define pr_info(fmt, ...) \ |
Joe Perches | a3f938b | 2011-01-12 16:59:48 -0800 | [diff] [blame] | 206 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 207 | #define pr_cont(fmt, ...) \ |
| 208 | printk(KERN_CONT fmt, ##__VA_ARGS__) |
| 209 | |
| 210 | /* pr_devel() should produce zero code unless DEBUG is defined */ |
| 211 | #ifdef DEBUG |
| 212 | #define pr_devel(fmt, ...) \ |
| 213 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 214 | #else |
| 215 | #define pr_devel(fmt, ...) \ |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 216 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 217 | #endif |
| 218 | |
| 219 | /* If you are writing a driver, please use dev_dbg instead */ |
Jim Cromie | b558c96 | 2011-12-19 17:11:18 -0500 | [diff] [blame] | 220 | #if defined(CONFIG_DYNAMIC_DEBUG) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 221 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ |
| 222 | #define pr_debug(fmt, ...) \ |
| 223 | dynamic_pr_debug(fmt, ##__VA_ARGS__) |
Jim Cromie | b558c96 | 2011-12-19 17:11:18 -0500 | [diff] [blame] | 224 | #elif defined(DEBUG) |
| 225 | #define pr_debug(fmt, ...) \ |
| 226 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 227 | #else |
| 228 | #define pr_debug(fmt, ...) \ |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 229 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 230 | #endif |
| 231 | |
| 232 | /* |
Joe Perches | 16cb839 | 2011-01-12 16:59:46 -0800 | [diff] [blame] | 233 | * Print a one-time message (analogous to WARN_ONCE() et al): |
| 234 | */ |
| 235 | |
| 236 | #ifdef CONFIG_PRINTK |
| 237 | #define printk_once(fmt, ...) \ |
| 238 | ({ \ |
| 239 | static bool __print_once; \ |
| 240 | \ |
| 241 | if (!__print_once) { \ |
| 242 | __print_once = true; \ |
| 243 | printk(fmt, ##__VA_ARGS__); \ |
| 244 | } \ |
| 245 | }) |
| 246 | #else |
| 247 | #define printk_once(fmt, ...) \ |
| 248 | no_printk(fmt, ##__VA_ARGS__) |
| 249 | #endif |
| 250 | |
| 251 | #define pr_emerg_once(fmt, ...) \ |
| 252 | printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
| 253 | #define pr_alert_once(fmt, ...) \ |
| 254 | printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
| 255 | #define pr_crit_once(fmt, ...) \ |
| 256 | printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
| 257 | #define pr_err_once(fmt, ...) \ |
| 258 | printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
| 259 | #define pr_warn_once(fmt, ...) \ |
| 260 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
| 261 | #define pr_notice_once(fmt, ...) \ |
| 262 | printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
| 263 | #define pr_info_once(fmt, ...) \ |
| 264 | printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
| 265 | #define pr_cont_once(fmt, ...) \ |
| 266 | printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) |
Mikhail Gruzdev | 36d308d | 2013-02-21 16:43:10 -0800 | [diff] [blame] | 267 | |
| 268 | #if defined(DEBUG) |
| 269 | #define pr_devel_once(fmt, ...) \ |
| 270 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 271 | #else |
| 272 | #define pr_devel_once(fmt, ...) \ |
| 273 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 274 | #endif |
| 275 | |
Joe Perches | 16cb839 | 2011-01-12 16:59:46 -0800 | [diff] [blame] | 276 | /* If you are writing a driver, please use dev_dbg instead */ |
| 277 | #if defined(DEBUG) |
| 278 | #define pr_debug_once(fmt, ...) \ |
| 279 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 280 | #else |
| 281 | #define pr_debug_once(fmt, ...) \ |
| 282 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 283 | #endif |
| 284 | |
| 285 | /* |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 286 | * ratelimited messages with local ratelimit_state, |
| 287 | * no local ratelimit_state used in the !PRINTK case |
| 288 | */ |
| 289 | #ifdef CONFIG_PRINTK |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 290 | #define printk_ratelimited(fmt, ...) \ |
| 291 | ({ \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 292 | static DEFINE_RATELIMIT_STATE(_rs, \ |
| 293 | DEFAULT_RATELIMIT_INTERVAL, \ |
| 294 | DEFAULT_RATELIMIT_BURST); \ |
| 295 | \ |
| 296 | if (__ratelimit(&_rs)) \ |
| 297 | printk(fmt, ##__VA_ARGS__); \ |
| 298 | }) |
| 299 | #else |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 300 | #define printk_ratelimited(fmt, ...) \ |
| 301 | no_printk(fmt, ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 302 | #endif |
| 303 | |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 304 | #define pr_emerg_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 305 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 306 | #define pr_alert_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 307 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 308 | #define pr_crit_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 309 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 310 | #define pr_err_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 311 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 312 | #define pr_warn_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 313 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 314 | #define pr_notice_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 315 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 316 | #define pr_info_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 317 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
| 318 | /* no pr_cont_ratelimited, don't do that... */ |
Mikhail Gruzdev | 36d308d | 2013-02-21 16:43:10 -0800 | [diff] [blame] | 319 | |
| 320 | #if defined(DEBUG) |
| 321 | #define pr_devel_ratelimited(fmt, ...) \ |
| 322 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 323 | #else |
| 324 | #define pr_devel_ratelimited(fmt, ...) \ |
| 325 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 326 | #endif |
| 327 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 328 | /* If you are writing a driver, please use dev_dbg instead */ |
| 329 | #if defined(DEBUG) |
Joe Perches | 6ec42a56 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 330 | #define pr_debug_ratelimited(fmt, ...) \ |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 331 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 332 | #else |
| 333 | #define pr_debug_ratelimited(fmt, ...) \ |
Joe Perches | 5264f2f | 2011-01-12 16:59:45 -0800 | [diff] [blame] | 334 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 335 | #endif |
| 336 | |
Kay Sievers | e11fea9 | 2012-05-03 02:29:41 +0200 | [diff] [blame] | 337 | extern const struct file_operations kmsg_fops; |
| 338 | |
Joe Perches | ac83ed6 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 339 | enum { |
| 340 | DUMP_PREFIX_NONE, |
| 341 | DUMP_PREFIX_ADDRESS, |
| 342 | DUMP_PREFIX_OFFSET |
| 343 | }; |
| 344 | extern void hex_dump_to_buffer(const void *buf, size_t len, |
| 345 | int rowsize, int groupsize, |
| 346 | char *linebuf, size_t linebuflen, bool ascii); |
| 347 | #ifdef CONFIG_PRINTK |
| 348 | extern void print_hex_dump(const char *level, const char *prefix_str, |
| 349 | int prefix_type, int rowsize, int groupsize, |
| 350 | const void *buf, size_t len, bool ascii); |
Vladimir Kondratiev | 7a55561 | 2012-12-05 16:48:27 -0500 | [diff] [blame] | 351 | #if defined(CONFIG_DYNAMIC_DEBUG) |
| 352 | #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ |
| 353 | dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true) |
| 354 | #else |
Joe Perches | ac83ed6 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 355 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, |
| 356 | const void *buf, size_t len); |
Vladimir Kondratiev | 7a55561 | 2012-12-05 16:48:27 -0500 | [diff] [blame] | 357 | #endif /* defined(CONFIG_DYNAMIC_DEBUG) */ |
Joe Perches | ac83ed6 | 2011-01-12 16:59:47 -0800 | [diff] [blame] | 358 | #else |
| 359 | static inline void print_hex_dump(const char *level, const char *prefix_str, |
| 360 | int prefix_type, int rowsize, int groupsize, |
| 361 | const void *buf, size_t len, bool ascii) |
| 362 | { |
| 363 | } |
| 364 | static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type, |
| 365 | const void *buf, size_t len) |
| 366 | { |
| 367 | } |
| 368 | |
| 369 | #endif |
| 370 | |
Vladimir Kondratiev | 7a55561 | 2012-12-05 16:48:27 -0500 | [diff] [blame] | 371 | #if defined(CONFIG_DYNAMIC_DEBUG) |
| 372 | #define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ |
| 373 | groupsize, buf, len, ascii) \ |
| 374 | dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ |
| 375 | groupsize, buf, len, ascii) |
| 376 | #else |
| 377 | #define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ |
| 378 | groupsize, buf, len, ascii) \ |
| 379 | print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \ |
| 380 | groupsize, buf, len, ascii) |
| 381 | #endif /* defined(CONFIG_DYNAMIC_DEBUG) */ |
| 382 | |
Linus Torvalds | 968ab18 | 2010-11-15 13:37:37 -0800 | [diff] [blame] | 383 | #endif |