Commit a0cba217 authored by Linus Torvalds's avatar Linus Torvalds

Revert "printk: create pr_<level> functions"

This reverts commit 874f9c7d.

Geert Uytterhoeven reports:
 "This change seems to have an (unintendent?) side-effect.

  Before, pr_*() calls without a trailing newline characters would be
  printed with a newline character appended, both on the console and in
  the output of the dmesg command.

  After this commit, no new line character is appended, and the output
  of the next pr_*() call of the same type may be appended, like in:

    - Truncating RAM at 0x0000000040000000-0x00000000c0000000 to -0x0000000070000000
    - Ignoring RAM at 0x0000000200000000-0x0000000240000000 (!CONFIG_HIGHMEM)
    + Truncating RAM at 0x0000000040000000-0x00000000c0000000 to -0x0000000070000000Ignoring RAM at 0x0000000200000000-0x0000000240000000 (!CONFIG_HIGHMEM)"

Joe Perches says:
 "No, that is not intentional.

  The newline handling code inside vprintk_emit is a bit involved and
  for now I suggest a revert until this has all the same behavior as
  earlier"
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Requested-by: default avatarJoe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 84bd8d33
...@@ -266,39 +266,21 @@ extern asmlinkage void dump_stack(void) __cold; ...@@ -266,39 +266,21 @@ extern asmlinkage void dump_stack(void) __cold;
* and other debug macros are compiled out unless either DEBUG is defined * and other debug macros are compiled out unless either DEBUG is defined
* or CONFIG_DYNAMIC_DEBUG is set. * or CONFIG_DYNAMIC_DEBUG is set.
*/ */
#define pr_emerg(fmt, ...) \
#ifdef CONFIG_PRINTK printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert(fmt, ...) \
asmlinkage __printf(1, 2) __cold void __pr_emerg(const char *fmt, ...); printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
asmlinkage __printf(1, 2) __cold void __pr_alert(const char *fmt, ...); #define pr_crit(fmt, ...) \
asmlinkage __printf(1, 2) __cold void __pr_crit(const char *fmt, ...); printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
asmlinkage __printf(1, 2) __cold void __pr_err(const char *fmt, ...); #define pr_err(fmt, ...) \
asmlinkage __printf(1, 2) __cold void __pr_warn(const char *fmt, ...); printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
asmlinkage __printf(1, 2) __cold void __pr_notice(const char *fmt, ...); #define pr_warning(fmt, ...) \
asmlinkage __printf(1, 2) __cold void __pr_info(const char *fmt, ...); printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warn pr_warning
#define pr_emerg(fmt, ...) __pr_emerg(pr_fmt(fmt), ##__VA_ARGS__) #define pr_notice(fmt, ...) \
#define pr_alert(fmt, ...) __pr_alert(pr_fmt(fmt), ##__VA_ARGS__) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit(fmt, ...) __pr_crit(pr_fmt(fmt), ##__VA_ARGS__) #define pr_info(fmt, ...) \
#define pr_err(fmt, ...) __pr_err(pr_fmt(fmt), ##__VA_ARGS__) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warn(fmt, ...) __pr_warn(pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) __pr_notice(pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) __pr_info(pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_emerg(fmt, ...) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#endif
#define pr_warning pr_warn
/* /*
* Like KERN_CONT, pr_cont() should only be used when continuing * Like KERN_CONT, pr_cont() should only be used when continuing
* a line with no newline ('\n') enclosed. Otherwise it defaults * a line with no newline ('\n') enclosed. Otherwise it defaults
......
...@@ -16,11 +16,9 @@ ...@@ -16,11 +16,9 @@
*/ */
#include <linux/percpu.h> #include <linux/percpu.h>
typedef __printf(2, 0) int (*printk_func_t)(int level, const char *fmt, typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
va_list args);
__printf(2, 0) int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
int vprintk_default(int level, const char *fmt, va_list args);
#ifdef CONFIG_PRINTK_NMI #ifdef CONFIG_PRINTK_NMI
...@@ -33,10 +31,9 @@ extern raw_spinlock_t logbuf_lock; ...@@ -33,10 +31,9 @@ extern raw_spinlock_t logbuf_lock;
* via per-CPU variable. * via per-CPU variable.
*/ */
DECLARE_PER_CPU(printk_func_t, printk_func); DECLARE_PER_CPU(printk_func_t, printk_func);
__printf(2, 0) static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
static inline int vprintk_func(int level, const char *fmt, va_list args)
{ {
return this_cpu_read(printk_func)(level, fmt, args); return this_cpu_read(printk_func)(fmt, args);
} }
extern atomic_t nmi_message_lost; extern atomic_t nmi_message_lost;
...@@ -47,10 +44,9 @@ static inline int get_nmi_message_lost(void) ...@@ -47,10 +44,9 @@ static inline int get_nmi_message_lost(void)
#else /* CONFIG_PRINTK_NMI */ #else /* CONFIG_PRINTK_NMI */
__printf(2, 0) static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
static inline int vprintk_func(int level, const char *fmt, va_list args)
{ {
return vprintk_default(level, fmt, args); return vprintk_default(fmt, args);
} }
static inline int get_nmi_message_lost(void) static inline int get_nmi_message_lost(void)
......
...@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq); ...@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq);
* one writer running. But the buffer might get flushed from another * one writer running. But the buffer might get flushed from another
* CPU, so we need to be careful. * CPU, so we need to be careful.
*/ */
static int vprintk_nmi(int level, const char *fmt, va_list args) static int vprintk_nmi(const char *fmt, va_list args)
{ {
struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq); struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
int add = 0; int add = 0;
...@@ -79,16 +79,7 @@ static int vprintk_nmi(int level, const char *fmt, va_list args) ...@@ -79,16 +79,7 @@ static int vprintk_nmi(int level, const char *fmt, va_list args)
if (!len) if (!len)
smp_rmb(); smp_rmb();
if (level != LOGLEVEL_DEFAULT) { add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
add = snprintf(s->buffer + len, sizeof(s->buffer) - len,
KERN_SOH "%c", '0' + level);
add += vsnprintf(s->buffer + len + add,
sizeof(s->buffer) - len - add,
fmt, args);
} else {
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len,
fmt, args);
}
/* /*
* Do it once again if the buffer has been flushed in the meantime. * Do it once again if the buffer has been flushed in the meantime.
......
...@@ -1930,26 +1930,7 @@ asmlinkage int printk_emit(int facility, int level, ...@@ -1930,26 +1930,7 @@ asmlinkage int printk_emit(int facility, int level,
} }
EXPORT_SYMBOL(printk_emit); EXPORT_SYMBOL(printk_emit);
#define define_pr_level(func, loglevel) \ int vprintk_default(const char *fmt, va_list args)
asmlinkage __visible void func(const char *fmt, ...) \
{ \
va_list args; \
\
va_start(args, fmt); \
vprintk_default(loglevel, fmt, args); \
va_end(args); \
} \
EXPORT_SYMBOL(func)
define_pr_level(__pr_emerg, LOGLEVEL_EMERG);
define_pr_level(__pr_alert, LOGLEVEL_ALERT);
define_pr_level(__pr_crit, LOGLEVEL_CRIT);
define_pr_level(__pr_err, LOGLEVEL_ERR);
define_pr_level(__pr_warn, LOGLEVEL_WARNING);
define_pr_level(__pr_notice, LOGLEVEL_NOTICE);
define_pr_level(__pr_info, LOGLEVEL_INFO);
int vprintk_default(int level, const char *fmt, va_list args)
{ {
int r; int r;
...@@ -1959,7 +1940,7 @@ int vprintk_default(int level, const char *fmt, va_list args) ...@@ -1959,7 +1940,7 @@ int vprintk_default(int level, const char *fmt, va_list args)
return r; return r;
} }
#endif #endif
r = vprintk_emit(0, level, NULL, 0, fmt, args); r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
return r; return r;
} }
...@@ -1992,7 +1973,7 @@ asmlinkage __visible int printk(const char *fmt, ...) ...@@ -1992,7 +1973,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
int r; int r;
va_start(args, fmt); va_start(args, fmt);
r = vprintk_func(LOGLEVEL_DEFAULT, fmt, args); r = vprintk_func(fmt, args);
va_end(args); va_end(args);
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment