From: Michal Schmidt <mschmidt@redhat.com> Date: Thu, 2 Sep 2010 23:23:49 -0400 Subject: [misc] kernel: add pr_* family of printk helper macros Message-id: <20100902232349.10621.91135.stgit@brian.englab.brq.redhat.com> Patchwork-id: 28038 O-Subject: [RHEL5.6 BZ629634 PATCH 3/5] kernel.h: add pr_*() family of printk helper macros Bugzilla: 629634 RH-Acked-by: David S. Miller <davem@redhat.com> RH-Acked-by: Jiri Pirko <jpirko@redhat.com> RH-Acked-by: Stanislaw Gruszka <sgruszka@redhat.com> RH-Acked-by: Prarit Bhargava <prarit@redhat.com> from upstream commits: 1f7c8234c7a68c2ccc2a33f3b7d48057980e7c35 d091c2f58ba32029495a933b721e8e02fbd12caa fc62f2f19edf46c9bdbd1a54725b56b18c43e94f 311d07611e8b354cc1ee6546e4c574c01111adc8 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index a4bf3ff..f35db2f 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -256,18 +256,37 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len); #define hex_asc(x) "0123456789abcdef"[x] -#ifdef DEBUG +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + +#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_warning(fmt, ...) \ + printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn pr_warning +#define pr_notice(fmt, ...) \ + printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) +#define pr_info(fmt, ...) \ + printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) +#define pr_cont(fmt, ...) \ + printk(KERN_CONT fmt, ##__VA_ARGS__) + /* If you are writing a driver, please use dev_dbg instead */ -#define pr_debug(fmt,arg...) \ - printk(KERN_DEBUG fmt,##arg) +#if defined(DEBUG) +#define pr_debug(fmt, ...) \ + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else -#define pr_debug(fmt,arg...) \ - do { } while (0) +#define pr_debug(fmt, ...) \ + ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) #endif -#define pr_info(fmt,arg...) \ - printk(KERN_INFO fmt,##arg) - /* * Display an IP address in readable format. */