iwlwifi: introduce host commands callbacks
[linux/fpc-iii.git] / drivers / mtd / ubi / debug.h
blob51c40b17f1ec5c967994666ad0f7f3ce4b689f39
1 /*
2 * Copyright (c) International Business Machines Corp., 2006
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author: Artem Bityutskiy (Битюцкий Артём)
21 #ifndef __UBI_DEBUG_H__
22 #define __UBI_DEBUG_H__
24 #ifdef CONFIG_MTD_UBI_DEBUG
25 #include <linux/random.h>
27 #define ubi_assert(expr) BUG_ON(!(expr))
28 #define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
29 #else
30 #define ubi_assert(expr) ({})
31 #define dbg_err(fmt, ...) ({})
32 #endif
34 #ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
35 #define DBG_DISABLE_BGT 1
36 #else
37 #define DBG_DISABLE_BGT 0
38 #endif
40 #ifdef CONFIG_MTD_UBI_DEBUG_MSG
41 /* Generic debugging message */
42 #define dbg_msg(fmt, ...) \
43 printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
44 current->pid, __FUNCTION__, ##__VA_ARGS__)
46 #define ubi_dbg_dump_stack() dump_stack()
48 struct ubi_ec_hdr;
49 struct ubi_vid_hdr;
50 struct ubi_volume;
51 struct ubi_vtbl_record;
52 struct ubi_scan_volume;
53 struct ubi_scan_leb;
54 struct ubi_mkvol_req;
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);
64 #else
66 #define dbg_msg(fmt, ...) ({})
67 #define ubi_dbg_dump_stack() ({})
68 #define ubi_dbg_dump_ec_hdr(ec_hdr) ({})
69 #define ubi_dbg_dump_vid_hdr(vid_hdr) ({})
70 #define ubi_dbg_dump_vol_info(vol) ({})
71 #define ubi_dbg_dump_vtbl_record(r, idx) ({})
72 #define ubi_dbg_dump_sv(sv) ({})
73 #define ubi_dbg_dump_seb(seb, type) ({})
74 #define ubi_dbg_dump_mkvol_req(req) ({})
76 #endif /* CONFIG_MTD_UBI_DEBUG_MSG */
78 #ifdef CONFIG_MTD_UBI_DEBUG_MSG_EBA
79 /* Messages from the eraseblock association unit */
80 #define dbg_eba(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
81 #else
82 #define dbg_eba(fmt, ...) ({})
83 #endif
85 #ifdef CONFIG_MTD_UBI_DEBUG_MSG_WL
86 /* Messages from the wear-leveling unit */
87 #define dbg_wl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
88 #else
89 #define dbg_wl(fmt, ...) ({})
90 #endif
92 #ifdef CONFIG_MTD_UBI_DEBUG_MSG_IO
93 /* Messages from the input/output unit */
94 #define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
95 #else
96 #define dbg_io(fmt, ...) ({})
97 #endif
99 #ifdef CONFIG_MTD_UBI_DEBUG_MSG_BLD
100 /* Initialization and build messages */
101 #define dbg_bld(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
102 #else
103 #define dbg_bld(fmt, ...) ({})
104 #endif
106 #ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS
108 * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip.
110 * Returns non-zero if a bit-flip should be emulated, otherwise returns zero.
112 static inline int ubi_dbg_is_bitflip(void)
114 return !(random32() % 200);
116 #else
117 #define ubi_dbg_is_bitflip() 0
118 #endif
120 #ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_WRITE_FAILURES
122 * ubi_dbg_is_write_failure - if it is time to emulate a write failure.
124 * Returns non-zero if a write failure should be emulated, otherwise returns
125 * zero.
127 static inline int ubi_dbg_is_write_failure(void)
129 return !(random32() % 500);
131 #else
132 #define ubi_dbg_is_write_failure() 0
133 #endif
135 #ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES
137 * ubi_dbg_is_erase_failure - if its time to emulate an erase failure.
139 * Returns non-zero if an erase failure should be emulated, otherwise returns
140 * zero.
142 static inline int ubi_dbg_is_erase_failure(void)
144 return !(random32() % 400);
146 #else
147 #define ubi_dbg_is_erase_failure() 0
148 #endif
150 #endif /* !__UBI_DEBUG_H__ */