Masahiro Yamada | b44b302 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 1 | #ifndef __KERNEL_PRINTK__ |
| 2 | #define __KERNEL_PRINTK__ |
| 3 | |
Heinrich Schuchardt | e86ad66 | 2021-01-04 08:02:55 +0100 | [diff] [blame] | 4 | #include <log.h> |
Masahiro Yamada | b44b302 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 5 | #include <stdio.h> |
| 6 | #include <linux/compiler.h> |
| 7 | |
| 8 | #define KERN_EMERG |
| 9 | #define KERN_ALERT |
| 10 | #define KERN_CRIT |
| 11 | #define KERN_ERR |
| 12 | #define KERN_WARNING |
| 13 | #define KERN_NOTICE |
| 14 | #define KERN_INFO |
| 15 | #define KERN_DEBUG |
| 16 | #define KERN_CONT |
| 17 | |
| 18 | #define printk(fmt, ...) \ |
| 19 | printf(fmt, ##__VA_ARGS__) |
| 20 | |
| 21 | /* |
| 22 | * Dummy printk for disabled debugging statements to use whilst maintaining |
| 23 | * gcc's format checking. |
| 24 | */ |
| 25 | #define no_printk(fmt, ...) \ |
| 26 | ({ \ |
| 27 | if (0) \ |
| 28 | printk(fmt, ##__VA_ARGS__); \ |
| 29 | 0; \ |
| 30 | }) |
| 31 | |
Masahiro Yamada | b44b302 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 32 | #ifndef pr_fmt |
| 33 | #define pr_fmt(fmt) fmt |
| 34 | #endif |
| 35 | |
Heinrich Schuchardt | e86ad66 | 2021-01-04 08:02:55 +0100 | [diff] [blame] | 36 | #define pr_emerg(fmt, ...) \ |
| 37 | ({ \ |
| 38 | CONFIG_LOGLEVEL > 0 ? log_emerg(fmt, ##__VA_ARGS__) : 0; \ |
| 39 | }) |
| 40 | #define pr_alert(fmt, ...) \ |
| 41 | ({ \ |
| 42 | CONFIG_LOGLEVEL > 1 ? log_alert(fmt, ##__VA_ARGS__) : 0; \ |
| 43 | }) |
| 44 | #define pr_crit(fmt, ...) \ |
| 45 | ({ \ |
| 46 | CONFIG_LOGLEVEL > 2 ? log_crit(fmt, ##__VA_ARGS__) : 0; \ |
| 47 | }) |
| 48 | #define pr_err(fmt, ...) \ |
| 49 | ({ \ |
| 50 | CONFIG_LOGLEVEL > 3 ? log_err(fmt, ##__VA_ARGS__) : 0; \ |
| 51 | }) |
| 52 | #define pr_warn(fmt, ...) \ |
| 53 | ({ \ |
| 54 | CONFIG_LOGLEVEL > 4 ? log_warning(fmt, ##__VA_ARGS__) : 0; \ |
| 55 | }) |
| 56 | #define pr_notice(fmt, ...) \ |
| 57 | ({ \ |
| 58 | CONFIG_LOGLEVEL > 5 ? log_notice(fmt, ##__VA_ARGS__) : 0; \ |
| 59 | }) |
| 60 | #define pr_info(fmt, ...) \ |
| 61 | ({ \ |
| 62 | CONFIG_LOGLEVEL > 6 ? log_info(fmt, ##__VA_ARGS__) : 0; \ |
| 63 | }) |
| 64 | #define pr_debug(fmt, ...) \ |
| 65 | ({ \ |
| 66 | CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0; \ |
| 67 | }) |
| 68 | #define pr_devel(fmt, ...) \ |
| 69 | ({ \ |
| 70 | CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0; \ |
| 71 | }) |
Masahiro Yamada | b44b302 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 72 | |
Heinrich Schuchardt | e86ad66 | 2021-01-04 08:02:55 +0100 | [diff] [blame] | 73 | #ifdef CONFIG_LOG |
| 74 | #define pr_cont(fmt, ...) \ |
| 75 | ({ \ |
| 76 | gd->logl_prev < CONFIG_LOGLEVEL ? \ |
| 77 | log_cont(fmt, ##__VA_ARGS__) : 0; \ |
| 78 | }) |
| 79 | #else |
| 80 | #define pr_cont(fmt, ...) \ |
Masahiro Yamada | b44b302 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 81 | printk(fmt, ##__VA_ARGS__) |
Masahiro Yamada | b44b302 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 82 | #endif |
| 83 | |
| 84 | #define printk_once(fmt, ...) \ |
| 85 | printk(fmt, ##__VA_ARGS__) |
| 86 | |
| 87 | #endif |