diff options
author | Joe Perches <joe@perches.com> | 2012-07-30 17:40:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:13 -0400 |
commit | acc8fa41ad31c576cdbc569cc3e0e443b1b98b44 (patch) | |
tree | 74b4072203646bd7432249e57f5a1505fa346b5e /include/linux/printk.h | |
parent | cdf53441368cc02ee4aa8a8343a5dc25132836f0 (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 'include/linux/printk.h')
-rw-r--r-- | include/linux/printk.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h index 1bec2f7a2d42..6e12e1f09047 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h | |||
@@ -24,6 +24,32 @@ extern const char linux_proc_banner[]; | |||
24 | */ | 24 | */ |
25 | #define KERN_CONT "<c>" | 25 | #define KERN_CONT "<c>" |
26 | 26 | ||
27 | static inline int printk_get_level(const char *buffer) | ||
28 | { | ||
29 | if (buffer[0] == '<' && buffer[1] && buffer[2] == '>') { | ||
30 | switch (buffer[1]) { | ||
31 | case '0' ... '7': | ||
32 | case 'd': /* KERN_DEFAULT */ | ||
33 | case 'c': /* KERN_CONT */ | ||
34 | return buffer[1]; | ||
35 | } | ||
36 | } | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | static inline const char *printk_skip_level(const char *buffer) | ||
41 | { | ||
42 | if (printk_get_level(buffer)) { | ||
43 | switch (buffer[1]) { | ||
44 | case '0' ... '7': | ||
45 | case 'd': /* KERN_DEFAULT */ | ||
46 | case 'c': /* KERN_CONT */ | ||
47 | return buffer + 3; | ||
48 | } | ||
49 | } | ||
50 | return buffer; | ||
51 | } | ||
52 | |||
27 | extern int console_printk[]; | 53 | extern int console_printk[]; |
28 | 54 | ||
29 | #define console_loglevel (console_printk[0]) | 55 | #define console_loglevel (console_printk[0]) |