Commit 07613b0b5ef8570033aa806d1731dce599862223
Committed by
Greg Kroah-Hartman
1 parent
27a90700a4
Exists in
master
and in
6 other branches
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>
Showing 1 changed file with 35 additions and 29 deletions Side-by-side Diff
include/linux/dynamic_debug.h
... | ... | @@ -54,35 +54,41 @@ |
54 | 54 | const char *fmt, ...) |
55 | 55 | __attribute__ ((format (printf, 3, 4))); |
56 | 56 | |
57 | -#define dynamic_pr_debug(fmt, ...) do { \ | |
58 | - static struct _ddebug descriptor \ | |
59 | - __used \ | |
60 | - __attribute__((section("__verbose"), aligned(8))) = \ | |
61 | - { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ | |
62 | - _DPRINTK_FLAGS_DEFAULT }; \ | |
63 | - if (unlikely(descriptor.enabled)) \ | |
64 | - __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ | |
65 | - } while (0) | |
57 | +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ | |
58 | + static struct _ddebug __used __aligned(8) \ | |
59 | + __attribute__((section("__verbose"))) name = { \ | |
60 | + .modname = KBUILD_MODNAME, \ | |
61 | + .function = __func__, \ | |
62 | + .filename = __FILE__, \ | |
63 | + .format = (fmt), \ | |
64 | + .lineno = __LINE__, \ | |
65 | + .flags = _DPRINTK_FLAGS_DEFAULT, \ | |
66 | + .enabled = false, \ | |
67 | + } | |
66 | 68 | |
67 | -#define dynamic_dev_dbg(dev, fmt, ...) do { \ | |
68 | - static struct _ddebug descriptor \ | |
69 | - __used \ | |
70 | - __attribute__((section("__verbose"), aligned(8))) = \ | |
71 | - { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ | |
72 | - _DPRINTK_FLAGS_DEFAULT }; \ | |
73 | - if (unlikely(descriptor.enabled)) \ | |
74 | - __dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \ | |
75 | - } while (0) | |
69 | +#define dynamic_pr_debug(fmt, ...) \ | |
70 | +do { \ | |
71 | + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ | |
72 | + if (unlikely(descriptor.enabled)) \ | |
73 | + __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \ | |
74 | + ##__VA_ARGS__); \ | |
75 | +} while (0) | |
76 | 76 | |
77 | -#define dynamic_netdev_dbg(dev, fmt, ...) do { \ | |
78 | - static struct _ddebug descriptor \ | |
79 | - __used \ | |
80 | - __attribute__((section("__verbose"), aligned(8))) = \ | |
81 | - { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ | |
82 | - _DPRINTK_FLAGS_DEFAULT }; \ | |
83 | - if (unlikely(descriptor.enabled)) \ | |
84 | - __dynamic_netdev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);\ | |
85 | - } while (0) | |
77 | +#define dynamic_dev_dbg(dev, fmt, ...) \ | |
78 | +do { \ | |
79 | + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ | |
80 | + if (unlikely(descriptor.enabled)) \ | |
81 | + __dynamic_dev_dbg(&descriptor, dev, fmt, \ | |
82 | + ##__VA_ARGS__); \ | |
83 | +} while (0) | |
84 | + | |
85 | +#define dynamic_netdev_dbg(dev, fmt, ...) \ | |
86 | +do { \ | |
87 | + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ | |
88 | + if (unlikely(descriptor.enabled)) \ | |
89 | + __dynamic_netdev_dbg(&descriptor, dev, fmt, \ | |
90 | + ##__VA_ARGS__); \ | |
91 | +} while (0) | |
86 | 92 | |
87 | 93 | #else |
88 | 94 |