Skip to content

Commit ab50ff6

Browse files
Artem BityutskiyArtem Bityutskiy
authored andcommitted
UBI: switch to dynamic printks
Remove custom dynamic prints and the module parameter to toggle them and use the generic kernel dynamic printk infrastructure. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
1 parent ebfce01 commit ab50ff6

2 files changed

Lines changed: 28 additions & 58 deletions

File tree

‎drivers/mtd/ubi/debug.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@
3030
#include <linux/module.h>
3131
#include <linux/moduleparam.h>
3232

33-
unsigned int ubi_msg_flags;
3433
unsigned int ubi_chk_flags;
3534
unsigned int ubi_tst_flags;
3635

37-
module_param_named(debug_msgs, ubi_msg_flags, uint, S_IRUGO | S_IWUSR);
3836
module_param_named(debug_chks, ubi_chk_flags, uint, S_IRUGO | S_IWUSR);
3937
module_param_named(debug_tsts, ubi_chk_flags, uint, S_IRUGO | S_IWUSR);
4038

41-
MODULE_PARM_DESC(debug_msgs, "Debug message type flags");
4239
MODULE_PARM_DESC(debug_chks, "Debug check flags");
4340
MODULE_PARM_DESC(debug_tsts, "Debug special test flags");
4441

‎drivers/mtd/ubi/debug.h‎

Lines changed: 28 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ struct ubi_mkvol_req;
3232
#ifdef CONFIG_MTD_UBI_DEBUG
3333
#include <linux/random.h>
3434

35-
#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
36-
3735
#define ubi_assert(expr) do { \
3836
if (unlikely(!(expr))) { \
3937
printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \
@@ -42,62 +40,37 @@ struct ubi_mkvol_req;
4240
} \
4341
} while (0)
4442

45-
#define dbg_msg(fmt, ...) \
46-
printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
47-
current->pid, __func__, ##__VA_ARGS__)
48-
49-
#define dbg_do_msg(typ, fmt, ...) do { \
50-
if (ubi_msg_flags & typ) \
51-
dbg_msg(fmt, ##__VA_ARGS__); \
52-
} while (0)
43+
#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
5344

5445
#define ubi_dbg_dump_stack() dump_stack()
5546

56-
void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
57-
void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
58-
void ubi_dbg_dump_vol_info(const struct ubi_volume *vol);
59-
void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
60-
void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv);
61-
void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type);
62-
void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
63-
void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
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-
8447
#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
8548
print_hex_dump(l, ps, pt, r, g, b, len, a)
8649

87-
/* General debugging messages */
88-
#define dbg_gen(fmt, ...) dbg_do_msg(UBI_MSG_GEN, fmt, ##__VA_ARGS__)
50+
#define ubi_dbg_msg(type, fmt, ...) \
51+
pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__)
8952

53+
/* Just a debugging messages not related to any specific UBI subsystem */
54+
#define dbg_msg(fmt, ...) ubi_dbg_msg("msg", fmt, ##__VA_ARGS__)
55+
/* General debugging messages */
56+
#define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
9057
/* Messages from the eraseblock association sub-system */
91-
#define dbg_eba(fmt, ...) dbg_do_msg(UBI_MSG_EBA, fmt, ##__VA_ARGS__)
92-
58+
#define dbg_eba(fmt, ...) ubi_dbg_msg("eba", fmt, ##__VA_ARGS__)
9359
/* Messages from the wear-leveling sub-system */
94-
#define dbg_wl(fmt, ...) dbg_do_msg(UBI_MSG_WL, fmt, ##__VA_ARGS__)
95-
60+
#define dbg_wl(fmt, ...) ubi_dbg_msg("wl", fmt, ##__VA_ARGS__)
9661
/* Messages from the input/output sub-system */
97-
#define dbg_io(fmt, ...) dbg_do_msg(UBI_MSG_IO, fmt, ##__VA_ARGS__)
98-
62+
#define dbg_io(fmt, ...) ubi_dbg_msg("io", fmt, ##__VA_ARGS__)
9963
/* Initialization and build messages */
100-
#define dbg_bld(fmt, ...) dbg_do_msg(UBI_MSG_BLD, fmt, ##__VA_ARGS__)
64+
#define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__)
65+
66+
void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
67+
void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
68+
void ubi_dbg_dump_vol_info(const struct ubi_volume *vol);
69+
void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
70+
void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv);
71+
void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type);
72+
void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
73+
void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
10174

10275
extern unsigned int ubi_chk_flags;
10376

@@ -197,17 +170,17 @@ static inline int ubi_dbg_is_erase_failure(void)
197170
ubi_err(fmt, ##__VA_ARGS__); \
198171
} while (0)
199172

200-
#define dbg_msg(fmt, ...) do { \
173+
#define ubi_dbg_msg(fmt, ...) do { \
201174
if (0) \
202-
printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
203-
current->pid, __func__, ##__VA_ARGS__); \
175+
pr_debug(fmt "\n", ##__VA_ARGS__); \
204176
} while (0)
205177

206-
#define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
207-
#define dbg_eba(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
208-
#define dbg_wl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
209-
#define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
210-
#define dbg_bld(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
178+
#define dbg_msg(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
179+
#define dbg_gen(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
180+
#define dbg_eba(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
181+
#define dbg_wl(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
182+
#define dbg_io(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
183+
#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
211184

212185
static inline void ubi_dbg_dump_stack(void) { return; }
213186
static inline void

0 commit comments

Comments
 (0)