aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-07-30 17:40:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:13 -0400
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,
1487 size_t text_len; 1487 size_t text_len;
1488 enum log_flags lflags = 0; 1488 enum log_flags lflags = 0;
1489 unsigned long flags; 1489 unsigned long flags;
1490 int kern_level;
1490 int this_cpu; 1491 int this_cpu;
1491 int printed_len = 0; 1492 int printed_len = 0;
1492 1493
@@ -1543,17 +1544,20 @@ asmlinkage int vprintk_emit(int facility, int level,
1543 } 1544 }
1544 1545
1545 /* strip syslog prefix and extract log level or control flags */ 1546 /* strip syslog prefix and extract log level or control flags */
1546 if (text[0] == '<' && text[1] && text[2] == '>') { 1547 kern_level = printk_get_level(text);
1547 switch (text[1]) { 1548 if (kern_level) {
1549 const char *end_of_header = printk_skip_level(text);
1550 switch (kern_level) {
1548 case '0' ... '7': 1551 case '0' ... '7':
1549 if (level == -1) 1552 if (level == -1)
1550 level = text[1] - '0'; 1553 level = kern_level - '0';
1551 case 'd': /* KERN_DEFAULT */ 1554 case 'd': /* KERN_DEFAULT */
1552 lflags |= LOG_PREFIX; 1555 lflags |= LOG_PREFIX;
1553 case 'c': /* KERN_CONT */ 1556 case 'c': /* KERN_CONT */
1554 text += 3; 1557 break;
1555 text_len -= 3;
1556 } 1558 }
1559 text_len -= end_of_header - text;
1560 text = (char *)end_of_header;
1557 } 1561 }
1558 1562
1559 if (level == -1) 1563 if (level == -1)