summaryrefslogtreecommitdiff
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-07-30 14:40:09 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 17:25:13 -0700
commitacc8fa41ad31c576cdbc569cc3e0e443b1b98b44 (patch)
tree74b4072203646bd7432249e57f5a1505fa346b5e /kernel/printk.c
parentcdf53441368cc02ee4aa8a8343a5dc25132836f0 (diff)
printk: add generic functions to find KERN_<LEVEL> headers
The current form of a KERN_<LEVEL> is "<.>". Add printk_get_level and printk_skip_level functions to handle these formats. These functions centralize tests of KERN_<LEVEL> so a future modification can change the KERN_<LEVEL> style and shorten the number of bytes consumed by these headers. [akpm@linux-foundation.org: fix build error and warning] Signed-off-by: Joe Perches <joe@perches.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Wu Fengguang <wfg@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 852269adad25..0d882a2f231e 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1487,6 +1487,7 @@ asmlinkage int vprintk_emit(int facility, int level,
size_t text_len;
enum log_flags lflags = 0;
unsigned long flags;
+ int kern_level;
int this_cpu;
int printed_len = 0;
@@ -1543,17 +1544,20 @@ asmlinkage int vprintk_emit(int facility, int level,
}
/* strip syslog prefix and extract log level or control flags */
- if (text[0] == '<' && text[1] && text[2] == '>') {
- switch (text[1]) {
+ kern_level = printk_get_level(text);
+ if (kern_level) {
+ const char *end_of_header = printk_skip_level(text);
+ switch (kern_level) {
case '0' ... '7':
if (level == -1)
- level = text[1] - '0';
+ level = kern_level - '0';
case 'd': /* KERN_DEFAULT */
lflags |= LOG_PREFIX;
case 'c': /* KERN_CONT */
- text += 3;
- text_len -= 3;
+ break;
}
+ text_len -= end_of_header - text;
+ text = (char *)end_of_header;
}
if (level == -1)