This source file includes following definitions.
- ubi_dbg_is_bgt_disabled
- ubi_dbg_is_bitflip
- ubi_dbg_is_write_failure
- ubi_dbg_is_erase_failure
- ubi_dbg_chk_io
- ubi_dbg_chk_gen
- ubi_dbg_chk_fastmap
- ubi_enable_dbg_chk_fastmap
1
2
3
4
5
6
7
8 #ifndef __UBI_DEBUG_H__
9 #define __UBI_DEBUG_H__
10
11 void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
12 void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
13 void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
14
15 #include <linux/random.h>
16
17 #define ubi_assert(expr) do { \
18 if (unlikely(!(expr))) { \
19 pr_crit("UBI assert failed in %s at %u (pid %d)\n", \
20 __func__, __LINE__, current->pid); \
21 dump_stack(); \
22 } \
23 } while (0)
24
25 #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
26 print_hex_dump(l, ps, pt, r, g, b, len, a)
27
28 #define ubi_dbg_msg(type, fmt, ...) \
29 pr_debug("UBI DBG " type " (pid %d): " fmt "\n", current->pid, \
30 ##__VA_ARGS__)
31
32
33 #define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
34
35 #define dbg_eba(fmt, ...) ubi_dbg_msg("eba", fmt, ##__VA_ARGS__)
36
37 #define dbg_wl(fmt, ...) ubi_dbg_msg("wl", fmt, ##__VA_ARGS__)
38
39 #define dbg_io(fmt, ...) ubi_dbg_msg("io", fmt, ##__VA_ARGS__)
40
41 #define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__)
42
43 void ubi_dump_vol_info(const struct ubi_volume *vol);
44 void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
45 void ubi_dump_av(const struct ubi_ainf_volume *av);
46 void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type);
47 void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req);
48 int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
49 int len);
50 int ubi_debugfs_init(void);
51 void ubi_debugfs_exit(void);
52 int ubi_debugfs_init_dev(struct ubi_device *ubi);
53 void ubi_debugfs_exit_dev(struct ubi_device *ubi);
54
55
56
57
58
59
60
61
62 static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
63 {
64 return ubi->dbg.disable_bgt;
65 }
66
67
68
69
70
71
72
73 static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
74 {
75 if (ubi->dbg.emulate_bitflips)
76 return !(prandom_u32() % 200);
77 return 0;
78 }
79
80
81
82
83
84
85
86
87 static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
88 {
89 if (ubi->dbg.emulate_io_failures)
90 return !(prandom_u32() % 500);
91 return 0;
92 }
93
94
95
96
97
98
99
100
101 static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
102 {
103 if (ubi->dbg.emulate_io_failures)
104 return !(prandom_u32() % 400);
105 return 0;
106 }
107
108 static inline int ubi_dbg_chk_io(const struct ubi_device *ubi)
109 {
110 return ubi->dbg.chk_io;
111 }
112
113 static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi)
114 {
115 return ubi->dbg.chk_gen;
116 }
117
118 static inline int ubi_dbg_chk_fastmap(const struct ubi_device *ubi)
119 {
120 return ubi->dbg.chk_fastmap;
121 }
122
123 static inline void ubi_enable_dbg_chk_fastmap(struct ubi_device *ubi)
124 {
125 ubi->dbg.chk_fastmap = 1;
126 }
127
128 int ubi_dbg_power_cut(struct ubi_device *ubi, int caller);
129 #endif