Commit 27a0f2a37aa46cb0174decddf8830715e5f1645a
1 parent
2a734bb8d5
Exists in
master
and in
4 other branches
UBI: prepare debugging stuff to further debugfs conversion
We'll need the 'struct ubi_device *ubi' pointer in every debugging function (to access the ->dbg field), so add this pointer to all the functions implementing UBI debugging test modes like 'ubi_dbg_is_bitflip()' etc. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Showing 3 changed files with 20 additions and 13 deletions Side-by-side Diff
drivers/mtd/ubi/debug.h
... | ... | @@ -126,21 +126,23 @@ |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * ubi_dbg_is_bgt_disabled - if the background thread is disabled. |
129 | + * @ubi: UBI device description object | |
129 | 130 | * |
130 | 131 | * Returns non-zero if the UBI background thread is disabled for testing |
131 | 132 | * purposes. |
132 | 133 | */ |
133 | -static inline int ubi_dbg_is_bgt_disabled(void) | |
134 | +static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) | |
134 | 135 | { |
135 | 136 | return ubi_tst_flags & UBI_TST_DISABLE_BGT; |
136 | 137 | } |
137 | 138 | |
138 | 139 | /** |
139 | 140 | * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip. |
141 | + * @ubi: UBI device description object | |
140 | 142 | * |
141 | 143 | * Returns non-zero if a bit-flip should be emulated, otherwise returns zero. |
142 | 144 | */ |
143 | -static inline int ubi_dbg_is_bitflip(void) | |
145 | +static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) | |
144 | 146 | { |
145 | 147 | if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS) |
146 | 148 | return !(random32() % 200); |
147 | 149 | |
... | ... | @@ -149,11 +151,12 @@ |
149 | 151 | |
150 | 152 | /** |
151 | 153 | * ubi_dbg_is_write_failure - if it is time to emulate a write failure. |
154 | + * @ubi: UBI device description object | |
152 | 155 | * |
153 | 156 | * Returns non-zero if a write failure should be emulated, otherwise returns |
154 | 157 | * zero. |
155 | 158 | */ |
156 | -static inline int ubi_dbg_is_write_failure(void) | |
159 | +static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) | |
157 | 160 | { |
158 | 161 | if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES) |
159 | 162 | return !(random32() % 500); |
160 | 163 | |
... | ... | @@ -162,11 +165,12 @@ |
162 | 165 | |
163 | 166 | /** |
164 | 167 | * ubi_dbg_is_erase_failure - if its time to emulate an erase failure. |
168 | + * @ubi: UBI device description object | |
165 | 169 | * |
166 | 170 | * Returns non-zero if an erase failure should be emulated, otherwise returns |
167 | 171 | * zero. |
168 | 172 | */ |
169 | -static inline int ubi_dbg_is_erase_failure(void) | |
173 | +static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) | |
170 | 174 | { |
171 | 175 | if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES) |
172 | 176 | return !(random32() % 400); |
... | ... | @@ -233,10 +237,13 @@ |
233 | 237 | static inline int ubi_debugfs_init_dev(struct ubi_device *ubi) { return 0; } |
234 | 238 | static inline void ubi_debugfs_exit_dev(struct ubi_device *ubi) { return; } |
235 | 239 | |
236 | -static inline int ubi_dbg_is_bgt_disabled(void) { return 0; } | |
237 | -static inline int ubi_dbg_is_bitflip(void) { return 0; } | |
238 | -static inline int ubi_dbg_is_write_failure(void) { return 0; } | |
239 | -static inline int ubi_dbg_is_erase_failure(void) { return 0; } | |
240 | +static inline int | |
241 | +ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) { return 0; } | |
242 | +static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) { return 0; } | |
243 | +static inline int | |
244 | +ubi_dbg_is_write_failure(const struct ubi_device *ubi) { return 0; } | |
245 | +static inline int | |
246 | +ubi_dbg_is_erase_failure(const struct ubi_device *ubi) { return 0; } | |
240 | 247 | |
241 | 248 | #endif /* !CONFIG_MTD_UBI_DEBUG */ |
242 | 249 | #endif /* !__UBI_DEBUG_H__ */ |
drivers/mtd/ubi/io.c
... | ... | @@ -212,7 +212,7 @@ |
212 | 212 | } else { |
213 | 213 | ubi_assert(len == read); |
214 | 214 | |
215 | - if (ubi_dbg_is_bitflip()) { | |
215 | + if (ubi_dbg_is_bitflip(ubi)) { | |
216 | 216 | dbg_gen("bit-flip (emulated)"); |
217 | 217 | err = UBI_IO_BITFLIPS; |
218 | 218 | } |
... | ... | @@ -281,7 +281,7 @@ |
281 | 281 | return err; |
282 | 282 | } |
283 | 283 | |
284 | - if (ubi_dbg_is_write_failure()) { | |
284 | + if (ubi_dbg_is_write_failure(ubi)) { | |
285 | 285 | dbg_err("cannot write %d bytes to PEB %d:%d " |
286 | 286 | "(emulated)", len, pnum, offset); |
287 | 287 | ubi_dbg_dump_stack(); |
... | ... | @@ -396,7 +396,7 @@ |
396 | 396 | if (err) |
397 | 397 | return err; |
398 | 398 | |
399 | - if (ubi_dbg_is_erase_failure()) { | |
399 | + if (ubi_dbg_is_erase_failure(ubi)) { | |
400 | 400 | dbg_err("cannot erase PEB %d (emulated)", pnum); |
401 | 401 | return -EIO; |
402 | 402 | } |
drivers/mtd/ubi/wl.c
... | ... | @@ -616,7 +616,7 @@ |
616 | 616 | list_add_tail(&wrk->list, &ubi->works); |
617 | 617 | ubi_assert(ubi->works_count >= 0); |
618 | 618 | ubi->works_count += 1; |
619 | - if (ubi->thread_enabled && !ubi_dbg_is_bgt_disabled()) | |
619 | + if (ubi->thread_enabled && !ubi_dbg_is_bgt_disabled(ubi)) | |
620 | 620 | wake_up_process(ubi->bgt_thread); |
621 | 621 | spin_unlock(&ubi->wl_lock); |
622 | 622 | } |
... | ... | @@ -1367,7 +1367,7 @@ |
1367 | 1367 | |
1368 | 1368 | spin_lock(&ubi->wl_lock); |
1369 | 1369 | if (list_empty(&ubi->works) || ubi->ro_mode || |
1370 | - !ubi->thread_enabled || ubi_dbg_is_bgt_disabled()) { | |
1370 | + !ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) { | |
1371 | 1371 | set_current_state(TASK_INTERRUPTIBLE); |
1372 | 1372 | spin_unlock(&ubi->wl_lock); |
1373 | 1373 | schedule(); |