From 096a27e708de767ea7b7f8ee98a74bcaacc30083 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Mar 2013 15:08:01 -0700 Subject: [PATCH] compat: backport print_hex_dump_debug() This backports print_hex_dump_debug() from commit 7a555613, which itself required a definition from commit 07613b0b. mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 7a555613 v3.9-rc1~128^2~135 mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 07613b0b v3.2-rc1~184^2~6 commit 7a555613eb77c69eb6e48b61bc5f72dd42fa1780 Author: Vladimir Kondratiev Date: Wed Dec 5 16:48:27 2012 -0500 dynamic_debug: dynamic hex dump Introduce print_hex_dump_debug() that can be dynamically controlled, similar to pr_debug. Also, make print_hex_dump_bytes() dynamically controlled Implement only 'p' flag (_DPRINTK_FLAGS_PRINT) to keep it simple since hex dump prints multiple lines and long prefix would impact readability. To provide line/file etc. information, use pr_debug or similar before/after print_hex_dump_debug() Signed-off-by: Vladimir Kondratiev Signed-off-by: Jason Baron Signed-off-by: Greg Kroah-Hartman commit 07613b0b5ef8570033aa806d1731dce599862223 Author: Jason Baron Date: Tue Oct 4 14:13:15 2011 -0700 dynamic_debug: consolidate repetitive struct _ddebug descriptor definitions Replace the repetitive struct _ddebug descriptor definitions with a new DECLARE_DYNAMIC_DEBUG_META_DATA(name, fmt) macro. [akpm@linux-foundation.org: s/DECLARE/DEFINE/] Signed-off-by: Jason Baron Cc: Arnd Bergmann Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.2.h | 16 ++++++++++++++++ include/linux/compat-3.9.h | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index cde86b564079..d23020687b26 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -7,6 +7,22 @@ #include #include +#include + +/* backports 07613b0b */ +#if defined(CONFIG_DYNAMIC_DEBUG) +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + static struct _ddebug __used __aligned(8) \ + __attribute__((section("__verbose"))) name = { \ + .modname = KBUILD_MODNAME, \ + .function = __func__, \ + .filename = __FILE__, \ + .format = (fmt), \ + .lineno = __LINE__, \ + .flags = _DPRINTK_FLAGS_DEFAULT, \ + .enabled = false, \ + } +#endif /* defined(CONFIG_DYNAMIC_DEBUG) */ /* backports b4625dab */ #define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */ diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h index 26e6f57c63d8..89b94a4532e1 100644 --- a/include/linux/compat-3.9.h +++ b/include/linux/compat-3.9.h @@ -13,10 +13,34 @@ #include #include #include +#include /* include this before changing hlist_for_each_* to use the old versions. */ #include +/* backports 7a555613 */ +#if defined(CONFIG_DYNAMIC_DEBUG) +#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, \ + __builtin_constant_p(prefix_str) ? prefix_str : "hexdump");\ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \ + print_hex_dump(KERN_DEBUG, prefix_str, \ + prefix_type, rowsize, groupsize, \ + buf, len, ascii); \ +} while (0) +#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) +#else +#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) +#endif /* defined(CONFIG_DYNAMIC_DEBUG) */ + /** * backport of idr idr_alloc() usage -- 2.30.2