UBI: improve checking in debugging prints
Subsystems (2)
PATCH 1/3 UBI: improve checking in debugging prints
From: Artem Bityutskiy <[email protected]>
When debugging is disabled, define debugging prints as if (0) printk() to make sure that the compiler still the format string in debugging messages even if debugging is disabled.
--- drivers/mtd/ubi/debug.h | 33 +++++++++++++++++++++++++-------- 1 files changed, 25 insertions(+), 8 deletions(-)
drivers/mtd/ubi/debug.h +25 -8
@@ -184,14 +184,31 @@ static inline int ubi_dbg_is_erase_failure(void)#else -#define ubi_assert (expr) ({}) -#define dbg_err (fmt, ...) ({}) -#define dbg_msg (fmt, ...) ({}) -#define dbg_gen (fmt, ...) ({}) -#define dbg_eba (fmt, ...) ({}) -#define dbg_wl (fmt, ...) ({}) -#define dbg_io (fmt, ...) ({}) -#define dbg_bld (fmt, ...) ({}) +/* Use "if (0)" to make compiler check arguments even if debugging is off */ +#define ubi_assert (expr) do { \ + if (0) { \ + printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ + __func__, __LINE__, current->pid); \ + } \ +} while (0) + +#define dbg_err (fmt, ...) do { \ + if (0) \ + ubi_err(fmt, ##__VA_ARGS__); \ +} while (0) + +#define dbg_msg (fmt, ...) do { \ + if (0) \ + printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \ + current->pid, __func__, ##__VA_ARGS__); \ +} while (0) + +#define dbg_gen (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) +#define dbg_eba (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) +#define dbg_wl (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) +#define dbg_io (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) +#define dbg_bld (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) +#define ubi_dbg_dump_stack () ({})#define ubi_dbg_dump_ec_hdr (ec_hdr) ({})#define ubi_dbg_dump_vid_hdr (vid_hdr) ({})
Signature · 1 line
1.7.2.3
PATCH 2/3 UBI: turn some macros into static inline
From: Artem Bityutskiy <[email protected]>
Similarly as we have done for UBIFS in 1dcffad74183bb00e8129ba1c5bb2c9931d31bd7, turn the debugging macros into static inline functions, for the same reasons: to avoid gcc 4.5 warnings.
--- drivers/mtd/ubi/debug.h | 63 ++++++++++++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 25 deletions(-)
drivers/mtd/ubi/debug.h +38 -25
@@ -21,6 +21,14 @@#ifndef __UBI_DEBUG_H__#define __UBI_DEBUG_H__ +struct ubi_ec_hdr ; +struct ubi_vid_hdr ; +struct ubi_volume ; +struct ubi_vtbl_record ; +struct ubi_scan_volume ; +struct ubi_scan_leb ; +struct ubi_mkvol_req ; +#ifdef CONFIG_MTD_UBI_DEBUG #include <linux/random.h>
@@ -45,14 +53,6 @@#define ubi_dbg_dump_stack () dump_stack() -struct ubi_ec_hdr ; -struct ubi_vid_hdr ; -struct ubi_volume ; -struct ubi_vtbl_record ; -struct ubi_scan_volume ; -struct ubi_scan_leb ; -struct ubi_mkvol_req ; -void ubi_dbg_dump_ec_hdr (const struct ubi_ec_hdr *ec_hdr);void ubi_dbg_dump_vid_hdr (const struct ubi_vid_hdr *vid_hdr);void ubi_dbg_dump_vol_info (const struct ubi_volume *vol);
@@ -209,23 +209,36 @@ static inline int ubi_dbg_is_erase_failure(void)#define dbg_io (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)#define dbg_bld (fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) -#define ubi_dbg_dump_stack () ({}) -#define ubi_dbg_dump_ec_hdr (ec_hdr) ({}) -#define ubi_dbg_dump_vid_hdr (vid_hdr) ({}) -#define ubi_dbg_dump_vol_info (vol) ({}) -#define ubi_dbg_dump_vtbl_record (r, idx) ({}) -#define ubi_dbg_dump_sv (sv) ({}) -#define ubi_dbg_dump_seb (seb, type) ({}) -#define ubi_dbg_dump_mkvol_req (req) ({}) -#define ubi_dbg_dump_flash (ubi, pnum, offset, len) ({}) -#define ubi_dbg_print_hex_dump (l, ps, pt, r, g, b, len, a) ({}) - -#define ubi_dbg_is_bgt_disabled () 0 -#define ubi_dbg_is_bitflip () 0 -#define ubi_dbg_is_write_failure () 0 -#define ubi_dbg_is_erase_failure () 0 -#define ubi_dbg_check_all_ff (ubi, pnum, offset, len) 0 -#define ubi_dbg_check_write (ubi, buf, pnum, offset, len) 0 +static inline void ubi_dbg_dump_stack (void ) {return ; } +static inline void +ubi_dbg_dump_ec_hdr (const struct ubi_ec_hdr *ec_hdr) {return ; } +static inline void +ubi_dbg_dump_vid_hdr (const struct ubi_vid_hdr *vid_hdr) {return ; } +static inline void +ubi_dbg_dump_vol_info (const struct ubi_volume *vol) {return ; } +static inline void +ubi_dbg_dump_vtbl_record (const struct ubi_vtbl_record *r,int idx) {return ; } +static inline void ubi_dbg_dump_sv (const struct ubi_scan_volume *sv) {return ; } +static inline void ubi_dbg_dump_seb (const struct ubi_scan_leb *seb, +int type) {return ; } +static inline void +ubi_dbg_dump_mkvol_req (const struct ubi_mkvol_req *req) {return ; } +static inline void ubi_dbg_dump_flash (struct ubi_device *ubi, +int pnum,int offset,int len) {return ; } +static inline void +ubi_dbg_print_hex_dump (const char *l,const char *ps,int pt,int r, +int g,const void *b,size_t len,bool a) {return ; } + +static inline int ubi_dbg_is_bgt_disabled (void ) {return 0 ; } +static inline int ubi_dbg_is_bitflip (void ) {return 0 ; } +static inline int ubi_dbg_is_write_failure (void ) {return 0 ; } +static inline int ubi_dbg_is_erase_failure (void ) {return 0 ; } +static inline int ubi_dbg_check_all_ff (struct ubi_device *ubi, +int pnum,int offset, +int len) {return 0 ; } +static inline int ubi_dbg_check_write (struct ubi_device *ubi, +const void *buf,int pnum, +int offset,int len) {return 0 ; }#endif /* !CONFIG_MTD_UBI_DEBUG */ #endif /* !__UBI_DEBUG_H__ */
Signature · 1 line
1.7.2.3
PATCH 3/3 UBI: switch to dynamic printks
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
Remove custom dynamic prints and the module parameter to toggle them and use the generic kernel dynamic printk infrastructure.
--- drivers/mtd/ubi/debug.c | 3 -- drivers/mtd/ubi/debug.h | 83 ++++++++++++++++------------------------------- 2 files changed, 28 insertions(+), 58 deletions(-)
drivers/mtd/ubi/debug.c +0 -3
@@ -30,15 +30,12 @@#include <linux/module.h> #include <linux/moduleparam.h> -unsigned int ubi_msg_flags;unsigned int ubi_chk_flags;unsigned int ubi_tst_flags; -module_param_named (debug_msgs, ubi_msg_flags, uint,S_IRUGO |S_IWUSR );module_param_named (debug_chks, ubi_chk_flags, uint,S_IRUGO |S_IWUSR );module_param_named (debug_tsts, ubi_chk_flags, uint,S_IRUGO |S_IWUSR ); -MODULE_PARM_DESC (debug_msgs,"Debug message type flags" );MODULE_PARM_DESC (debug_chks,"Debug check flags" );MODULE_PARM_DESC (debug_tsts,"Debug special test flags" );
drivers/mtd/ubi/debug.h +28 -55
115 lines not on this page · raw message
Signature · 1 line
1.7.2.3