* + printk-add-generic-functions-to-find-kern_level-headers.patch added to -mm tree
@ 2012-06-06 21:45 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2012-06-06 21:45 UTC (permalink / raw)
To: mm-commits; +Cc: joe, kay.sievers
The patch titled
Subject: printk: add generic functions to find KERN_<LEVEL> headers
has been added to the -mm tree. Its filename is
printk-add-generic-functions-to-find-kern_level-headers.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Joe Perches <joe@perches.com>
Subject: 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.
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/printk.h | 26 ++++++++++++++++++++++++++
kernel/printk.c | 13 ++++++++-----
2 files changed, 34 insertions(+), 5 deletions(-)
diff -puN include/linux/printk.h~printk-add-generic-functions-to-find-kern_level-headers include/linux/printk.h
--- a/include/linux/printk.h~printk-add-generic-functions-to-find-kern_level-headers
+++ a/include/linux/printk.h
@@ -24,6 +24,32 @@ extern const char linux_proc_banner[];
*/
#define KERN_CONT "<c>"
+static inline int printk_get_level(const char *buffer)
+{
+ if (buffer[0] == '<' && buffer[1] && buffer[2] == '>') {
+ switch (buffer[1]) {
+ case '0' ... '7':
+ case 'd': /* KERN_DEFAULT */
+ case 'c': /* KERN_CONT */
+ return buffer[1];
+ }
+ }
+ return 0;
+}
+
+static inline const char *printk_skip_level(const char *buffer)
+{
+ if (printk_get_level(buffer)) {
+ switch (buffer[1]) {
+ case '0' ... '7':
+ case 'd': /* KERN_DEFAULT */
+ case 'c': /* KERN_CONT */
+ return buffer + 3;
+ }
+ }
+ return buffer;
+}
+
extern int console_printk[];
#define console_loglevel (console_printk[0])
diff -puN kernel/printk.c~printk-add-generic-functions-to-find-kern_level-headers kernel/printk.c
--- a/kernel/printk.c~printk-add-generic-functions-to-find-kern_level-headers
+++ a/kernel/printk.c
@@ -1269,6 +1269,7 @@ asmlinkage int vprintk_emit(int facility
static char cont_buf[LOG_LINE_MAX];
static size_t cont_len;
static int cont_level;
+ int kern_level;
static struct task_struct *cont_task;
static char textbuf[LOG_LINE_MAX];
char *text = textbuf;
@@ -1331,17 +1332,19 @@ asmlinkage int vprintk_emit(int facility
}
/* 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 */
prefix = true;
case 'c': /* KERN_CONT */
- text += 3;
- text_len -= 3;
}
+ text_len -= end_of_header - text;
+ text = end_of_header;
}
if (level == -1)
_
Subject: Subject: printk: add generic functions to find KERN_<LEVEL> headers
Patches currently in -mm which might be from joe@perches.com are
linux-next.patch
maintainers-whitespace-fixes.patch
printk-add-generic-functions-to-find-kern_level-headers.patch
printk-add-kern_levelsh-to-make-kern_level-available-for-asm-use.patch
arch-remove-direct-definitions-of-kern_level-uses.patch
btrfs-use-printk_get_level-and-printk_skip_level-add-__printf-fix-fallout.patch
sound-use-printk_get_level-and-printk_skip_level.patch
staging-wlags49_h2-remove-direct-declarations-of-kern_level-prefixes.patch
printk-convert-the-format-for-kern_level-to-a-2-byte-pattern.patch
printk-only-look-for-prefix-levels-in-kernel-messages.patch
printk-remove-the-now-unnecessary-c-annotation-for-kern_cont.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-06 21:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-06 21:45 + printk-add-generic-functions-to-find-kern_level-headers.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.