Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dynamic_debug.h/kernel.h: Remove KBUILD_MODNAME from dynamic_pr_debug

If CONFIG_DYNAMIC_DEBUG is enabled and a source file has:

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>

dynamic_debug.h will duplicate KBUILD_MODNAME
in the output string.

Remove the use of KBUILD_MODNAME from the
output format string generated by dynamic_debug.h

If CONFIG_DYNAMIC_DEBUG is not enabled, no compile-time
check is done to printk/dev_printk arguments.

Add it.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joe Perches and committed by
Linus Torvalds
00b55864 42f247c8

+8 -10
+6 -7
include/linux/dynamic_debug.h
··· 57 57 { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ 58 58 DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ 59 59 if (__dynamic_dbg_enabled(descriptor)) \ 60 - printk(KERN_DEBUG KBUILD_MODNAME ":" pr_fmt(fmt), \ 61 - ##__VA_ARGS__); \ 60 + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ 62 61 } while (0) 63 62 64 63 ··· 68 69 { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ 69 70 DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ 70 71 if (__dynamic_dbg_enabled(descriptor)) \ 71 - dev_printk(KERN_DEBUG, dev, \ 72 - KBUILD_MODNAME ": " fmt, \ 73 - ##__VA_ARGS__); \ 72 + dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 74 73 } while (0) 75 74 76 75 #else ··· 78 81 return 0; 79 82 } 80 83 81 - #define dynamic_pr_debug(fmt, ...) do { } while (0) 82 - #define dynamic_dev_dbg(dev, format, ...) do { } while (0) 84 + #define dynamic_pr_debug(fmt, ...) \ 85 + do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) 86 + #define dynamic_dev_dbg(dev, format, ...) \ 87 + do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) 83 88 #endif 84 89 85 90 #endif
+2 -3
include/linux/kernel.h
··· 397 397 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 398 398 #elif defined(CONFIG_DYNAMIC_DEBUG) 399 399 /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ 400 - #define pr_debug(fmt, ...) do { \ 401 - dynamic_pr_debug(fmt, ##__VA_ARGS__); \ 402 - } while (0) 400 + #define pr_debug(fmt, ...) \ 401 + dynamic_pr_debug(fmt, ##__VA_ARGS__) 403 402 #else 404 403 #define pr_debug(fmt, ...) \ 405 404 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })