mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC v3 1/2] dynamic debug: add dynamic_hexdump_debug macro
@ 2011-03-02  1:24 Bing Zhao
  2011-03-02  1:24 ` [RFC v3 2/2] printk: add hexdump_debug macro Bing Zhao
  0 siblings, 1 reply; 2+ messages in thread
From: Bing Zhao @ 2011-03-02  1:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-wireless, Joe Perches, John W. Linville, Johannes Berg,
	Amitkumar Karwar, Kiran Divekar, Frank Huang, Bing Zhao

dynamic_hexdump_debug(str, buf, len)

str: "prefix string"
buf: buffer pointer
len: length of the buffer being printed

Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: use "str" as prefix string (Joe Perches)
v2: rebase against linux-next.git tree and split into 2 patches

 include/linux/dynamic_debug.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 0c9653f..06a7fed 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -70,6 +70,17 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
 	} while (0)
 
+#define dynamic_hexdump_debug(str, buf, len)				\
+do {									\
+	static struct _ddebug descriptor				\
+	__used								\
+	__attribute__((section("__verbose"), aligned(8))) =		\
+	{ KBUILD_MODNAME, __func__, __FILE__, str, __LINE__,		\
+		_DPRINTK_FLAGS_DEFAULT };				\
+	if (unlikely(descriptor.enabled))				\
+		print_hex_dump_bytes(str, DUMP_PREFIX_OFFSET, buf, len);\
+} while (0)
+
 #else
 
 static inline int ddebug_remove_module(const char *mod)
@@ -81,6 +92,9 @@ static inline int ddebug_remove_module(const char *mod)
 	do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
 #define dynamic_dev_dbg(dev, fmt, ...)					\
 	do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
+#define dynamic_hexdump_debug(str, buf, len)				\
+	do { if (0) print_hex_dump_bytes(str, DUMP_PREFIX_OFFSET,	\
+						buf, len); } while (0)
 #endif
 
 #endif
-- 
1.6.2.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [RFC v3 2/2] printk: add hexdump_debug macro
  2011-03-02  1:24 [RFC v3 1/2] dynamic debug: add dynamic_hexdump_debug macro Bing Zhao
@ 2011-03-02  1:24 ` Bing Zhao
  0 siblings, 0 replies; 2+ messages in thread
From: Bing Zhao @ 2011-03-02  1:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-wireless, Joe Perches, John W. Linville, Johannes Berg,
	Amitkumar Karwar, Kiran Divekar, Frank Huang, Bing Zhao

hexdump_debug(str, buf, len)

str: "prefix string"
buf: buffer pointer
len: length of the buffer being printed

usage:
hexdump_debug("mwifiex data_d: tx_buf: ", tx_buf, 32);

Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: use "str" as prefix string (Joe Perches)
v2: rebase against linux-next.git tree and split into 2 patches

 include/linux/printk.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index ee048e7..041ef6d 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -299,4 +299,15 @@ static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
 
 #endif
 
+#if defined(DEBUG)
+#define hexdump_debug(str, buf, len) \
+	print_hex_dump_bytes(str, DUMP_PREFIX_OFFSET, buf, len);
+#elif defined(CONFIG_DYNAMIC_DEBUG)
+#define hexdump_debug(str, buf, len) \
+	dynamic_hexdump_debug(str, buf, len)
+#else
+#define hexdump_debug(str, buf, len) \
+	no_printk(KERN_DEBUG str)
+#endif
+
 #endif
-- 
1.6.2.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-02  1:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02  1:24 [RFC v3 1/2] dynamic debug: add dynamic_hexdump_debug macro Bing Zhao
2011-03-02  1:24 ` [RFC v3 2/2] printk: add hexdump_debug macro Bing Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®