aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/CodingStyle22
-rw-r--r--include/linux/printk.h6
2 files changed, 21 insertions, 7 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 7fe0546c504a..6b6bef31e956 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -660,15 +660,23 @@ There are a number of driver model diagnostic macros in <linux/device.h>
660which you should use to make sure messages are matched to the right device 660which you should use to make sure messages are matched to the right device
661and driver, and are tagged with the right level: dev_err(), dev_warn(), 661and driver, and are tagged with the right level: dev_err(), dev_warn(),
662dev_info(), and so forth. For messages that aren't associated with a 662dev_info(), and so forth. For messages that aren't associated with a
663particular device, <linux/printk.h> defines pr_debug() and pr_info(). 663particular device, <linux/printk.h> defines pr_notice(), pr_info(),
664pr_warn(), pr_err(), etc.
664 665
665Coming up with good debugging messages can be quite a challenge; and once 666Coming up with good debugging messages can be quite a challenge; and once
666you have them, they can be a huge help for remote troubleshooting. Such 667you have them, they can be a huge help for remote troubleshooting. However
667messages should be compiled out when the DEBUG symbol is not defined (that 668debug message printing is handled differently than printing other non-debug
668is, by default they are not included). When you use dev_dbg() or pr_debug(), 669messages. While the other pr_XXX() functions print unconditionally,
669that's automatic. Many subsystems have Kconfig options to turn on -DDEBUG. 670pr_debug() does not; it is compiled out by default, unless either DEBUG is
670A related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to the 671defined or CONFIG_DYNAMIC_DEBUG is set. That is true for dev_dbg() also,
671ones already enabled by DEBUG. 672and a related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to
673the ones already enabled by DEBUG.
674
675Many subsystems have Kconfig debug options to turn on -DDEBUG in the
676corresponding Makefile; in other cases specific files #define DEBUG. And
677when a debug message should be unconditionally printed, such as if it is
678already inside a debug-related #ifdef secton, printk(KERN_DEBUG ...) can be
679used.
672 680
673 681
674 Chapter 14: Allocating memory 682 Chapter 14: Allocating memory
diff --git a/include/linux/printk.h b/include/linux/printk.h
index f086d6c99dbc..37f3a6589c1c 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -210,6 +210,12 @@ extern asmlinkage void dump_stack(void) __cold;
210#define pr_fmt(fmt) fmt 210#define pr_fmt(fmt) fmt
211#endif 211#endif
212 212
213/*
214 * These can be used to print at the various log levels.
215 * All of these will print unconditionally, although note that pr_debug()
216 * and other debug macros are compiled out unless either DEBUG is defined
217 * or CONFIG_DYNAMIC_DEBUG is set.
218 */
213#define pr_emerg(fmt, ...) \ 219#define pr_emerg(fmt, ...) \
214 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) 220 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
215#define pr_alert(fmt, ...) \ 221#define pr_alert(fmt, ...) \