diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-11 07:33:23 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-03-16 07:50:16 -0400 |
commit | b342efd4a49cef9cf1a260c1814aad97722f38f8 (patch) | |
tree | c2fecee23143d6939a719c9e6c5728c6f8798665 /drivers/mtd | |
parent | 6f9fdf62db64b1e52e5b7a9f785554e8b877b65c (diff) |
UBI: make debugging messages dynamic
This patch adds a possibility to dynamically select UBI debugging
messages, instead of selecting them compile-time from the configuration
menu. This is much more flexible, and consistent with UBIFS, and this
also simplifies UBI Kconfig menu and the code.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/Kconfig.debug | 30 | ||||
-rw-r--r-- | drivers/mtd/ubi/debug.c | 8 | ||||
-rw-r--r-- | drivers/mtd/ubi/debug.h | 54 |
3 files changed, 37 insertions, 55 deletions
diff --git a/drivers/mtd/ubi/Kconfig.debug b/drivers/mtd/ubi/Kconfig.debug index fad4adc0fe2c..d40134e9d572 100644 --- a/drivers/mtd/ubi/Kconfig.debug +++ b/drivers/mtd/ubi/Kconfig.debug | |||
@@ -10,11 +10,6 @@ config MTD_UBI_DEBUG | |||
10 | 10 | ||
11 | if MTD_UBI_DEBUG | 11 | if MTD_UBI_DEBUG |
12 | 12 | ||
13 | config MTD_UBI_DEBUG_MSG | ||
14 | bool "UBI debugging messages" | ||
15 | help | ||
16 | This option enables UBI debugging messages. | ||
17 | |||
18 | config MTD_UBI_DEBUG_PARANOID | 13 | config MTD_UBI_DEBUG_PARANOID |
19 | bool "Extra self-checks" | 14 | bool "Extra self-checks" |
20 | help | 15 | help |
@@ -45,29 +40,4 @@ config MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES | |||
45 | This option emulates erase failures with probability 1/100. Useful for | 40 | This option emulates erase failures with probability 1/100. Useful for |
46 | debugging and testing how UBI handlines errors. | 41 | debugging and testing how UBI handlines errors. |
47 | 42 | ||
48 | comment "Additional UBI debugging messages" | ||
49 | |||
50 | config MTD_UBI_DEBUG_MSG_BLD | ||
51 | bool "Additional UBI initialization and build messages" | ||
52 | help | ||
53 | This option enables detailed UBI initialization and device build | ||
54 | debugging messages. | ||
55 | |||
56 | config MTD_UBI_DEBUG_MSG_EBA | ||
57 | bool "Eraseblock association unit messages" | ||
58 | help | ||
59 | This option enables debugging messages from the UBI eraseblock | ||
60 | association unit. | ||
61 | |||
62 | config MTD_UBI_DEBUG_MSG_WL | ||
63 | bool "Wear-leveling unit messages" | ||
64 | help | ||
65 | This option enables debugging messages from the UBI wear-leveling | ||
66 | unit. | ||
67 | |||
68 | config MTD_UBI_DEBUG_MSG_IO | ||
69 | bool "Input/output unit messages" | ||
70 | help | ||
71 | This option enables debugging messages from the UBI input/output unit. | ||
72 | |||
73 | endif # MTD_UBI_DEBUG | 43 | endif # MTD_UBI_DEBUG |
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 4876977e52cb..8ae0bc7401ca 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c | |||
@@ -27,6 +27,14 @@ | |||
27 | #ifdef CONFIG_MTD_UBI_DEBUG | 27 | #ifdef CONFIG_MTD_UBI_DEBUG |
28 | 28 | ||
29 | #include "ubi.h" | 29 | #include "ubi.h" |
30 | #include <linux/module.h> | ||
31 | #include <linux/moduleparam.h> | ||
32 | |||
33 | unsigned int ubi_msg_flags; | ||
34 | |||
35 | module_param_named(debug_msgs, ubi_msg_flags, uint, S_IRUGO | S_IWUSR); | ||
36 | |||
37 | MODULE_PARM_DESC(debug_msgs, "Debug message type flags"); | ||
30 | 38 | ||
31 | /** | 39 | /** |
32 | * ubi_dbg_dump_ec_hdr - dump an erase counter header. | 40 | * ubi_dbg_dump_ec_hdr - dump an erase counter header. |
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 8bd1d17c1bd3..bee6fa1e5147 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h | |||
@@ -38,6 +38,11 @@ | |||
38 | printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \ | 38 | printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \ |
39 | current->pid, __func__, ##__VA_ARGS__) | 39 | current->pid, __func__, ##__VA_ARGS__) |
40 | 40 | ||
41 | #define dbg_do_msg(typ, fmt, ...) do { \ | ||
42 | if (ubi_msg_flags & typ) \ | ||
43 | dbg_msg(fmt, ##__VA_ARGS__); \ | ||
44 | } while (0) | ||
45 | |||
41 | #define ubi_dbg_dump_stack() dump_stack() | 46 | #define ubi_dbg_dump_stack() dump_stack() |
42 | 47 | ||
43 | struct ubi_ec_hdr; | 48 | struct ubi_ec_hdr; |
@@ -57,43 +62,42 @@ void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type); | |||
57 | void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req); | 62 | void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req); |
58 | void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len); | 63 | void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len); |
59 | 64 | ||
65 | extern unsigned int ubi_msg_flags; | ||
66 | |||
67 | /* | ||
68 | * Debugging message type flags (must match msg_type_names in debug.c). | ||
69 | * | ||
70 | * UBI_MSG_GEN: general messages | ||
71 | * UBI_MSG_EBA: journal messages | ||
72 | * UBI_MSG_WL: mount messages | ||
73 | * UBI_MSG_IO: commit messages | ||
74 | * UBI_MSG_BLD: LEB find messages | ||
75 | */ | ||
76 | enum { | ||
77 | UBI_MSG_GEN = 0x1, | ||
78 | UBI_MSG_EBA = 0x2, | ||
79 | UBI_MSG_WL = 0x4, | ||
80 | UBI_MSG_IO = 0x8, | ||
81 | UBI_MSG_BLD = 0x10, | ||
82 | }; | ||
83 | |||
60 | #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \ | 84 | #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \ |
61 | print_hex_dump(l, ps, pt, r, g, b, len, a) | 85 | print_hex_dump(l, ps, pt, r, g, b, len, a) |
62 | 86 | ||
63 | #ifdef CONFIG_MTD_UBI_DEBUG_MSG | ||
64 | /* General debugging messages */ | 87 | /* General debugging messages */ |
65 | #define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 88 | #define dbg_gen(fmt, ...) dbg_do_msg(UBI_MSG_GEN, fmt, ##__VA_ARGS__) |
66 | #else | ||
67 | #define dbg_gen(fmt, ...) ({}) | ||
68 | #endif | ||
69 | 89 | ||
70 | #ifdef CONFIG_MTD_UBI_DEBUG_MSG_EBA | ||
71 | /* Messages from the eraseblock association sub-system */ | 90 | /* Messages from the eraseblock association sub-system */ |
72 | #define dbg_eba(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 91 | #define dbg_eba(fmt, ...) dbg_do_msg(UBI_MSG_EBA, fmt, ##__VA_ARGS__) |
73 | #else | ||
74 | #define dbg_eba(fmt, ...) ({}) | ||
75 | #endif | ||
76 | 92 | ||
77 | #ifdef CONFIG_MTD_UBI_DEBUG_MSG_WL | ||
78 | /* Messages from the wear-leveling sub-system */ | 93 | /* Messages from the wear-leveling sub-system */ |
79 | #define dbg_wl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 94 | #define dbg_wl(fmt, ...) dbg_do_msg(UBI_MSG_WL, fmt, ##__VA_ARGS__) |
80 | #else | ||
81 | #define dbg_wl(fmt, ...) ({}) | ||
82 | #endif | ||
83 | 95 | ||
84 | #ifdef CONFIG_MTD_UBI_DEBUG_MSG_IO | ||
85 | /* Messages from the input/output sub-system */ | 96 | /* Messages from the input/output sub-system */ |
86 | #define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 97 | #define dbg_io(fmt, ...) dbg_do_msg(UBI_MSG_IO, fmt, ##__VA_ARGS__) |
87 | #else | ||
88 | #define dbg_io(fmt, ...) ({}) | ||
89 | #endif | ||
90 | 98 | ||
91 | #ifdef CONFIG_MTD_UBI_DEBUG_MSG_BLD | ||
92 | /* Initialization and build messages */ | 99 | /* Initialization and build messages */ |
93 | #define dbg_bld(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 100 | #define dbg_bld(fmt, ...) dbg_do_msg(UBI_MSG_BLD, fmt, ##__VA_ARGS__) |
94 | #else | ||
95 | #define dbg_bld(fmt, ...) ({}) | ||
96 | #endif | ||
97 | 101 | ||
98 | #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID | 102 | #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID |
99 | int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len); | 103 | int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len); |