compat: backport print_hex_dump_debug()
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Thu, 14 Mar 2013 22:08:01 +0000 (15:08 -0700)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Thu, 14 Mar 2013 22:15:37 +0000 (15:15 -0700)
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 <qca_vkondrat@qca.qualcomm.com>
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 <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 07613b0b5ef8570033aa806d1731dce599862223
Author: Jason Baron <jbaron@redhat.com>
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 <jbaron@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
include/linux/compat-3.2.h
include/linux/compat-3.9.h

index cde86b564079dc427e9c126f89db6215c241b601..d23020687b268a9fda2c4f3ee8e87c2d34574992 100644 (file)
@@ -7,6 +7,22 @@
 
 #include <linux/skbuff.h>
 #include <linux/dma-mapping.h>
+#include <linux/printk.h>
+
+/* 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 */
index 26e6f57c63d829ff33dd5c696cee9f67551acb4a..89b94a4532e11ac4a66d57a1281c2fe60b6f3ca4 100644 (file)
 #include <net/sock.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
+#include <linux/printk.h>
 
 /* include this before changing hlist_for_each_* to use the old versions. */
 #include <net/sch_generic.h>
 
+/* 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