diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-18 09:03:23 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-06-01 04:21:52 -0400 |
commit | 27a0f2a37aa46cb0174decddf8830715e5f1645a (patch) | |
tree | 7c370fdb171bf017161d2cc3911de179516bca0d /drivers/mtd | |
parent | 2a734bb8d502b645c061fa329e87c5d651498e68 (diff) |
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/debug.h | 23 | ||||
-rw-r--r-- | drivers/mtd/ubi/io.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/wl.c | 4 |
3 files changed, 20 insertions, 13 deletions
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index cb6c87977be..efefc549fee 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h | |||
@@ -126,21 +126,23 @@ enum { | |||
126 | 126 | ||
127 | /** | 127 | /** |
128 | * ubi_dbg_is_bgt_disabled - if the background thread is disabled. | 128 | * ubi_dbg_is_bgt_disabled - if the background thread is disabled. |
129 | * @ubi: UBI device description object | ||
129 | * | 130 | * |
130 | * Returns non-zero if the UBI background thread is disabled for testing | 131 | * Returns non-zero if the UBI background thread is disabled for testing |
131 | * purposes. | 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 | return ubi_tst_flags & UBI_TST_DISABLE_BGT; | 136 | return ubi_tst_flags & UBI_TST_DISABLE_BGT; |
136 | } | 137 | } |
137 | 138 | ||
138 | /** | 139 | /** |
139 | * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip. | 140 | * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip. |
141 | * @ubi: UBI device description object | ||
140 | * | 142 | * |
141 | * Returns non-zero if a bit-flip should be emulated, otherwise returns zero. | 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 | if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS) | 147 | if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS) |
146 | return !(random32() % 200); | 148 | return !(random32() % 200); |
@@ -149,11 +151,12 @@ static inline int ubi_dbg_is_bitflip(void) | |||
149 | 151 | ||
150 | /** | 152 | /** |
151 | * ubi_dbg_is_write_failure - if it is time to emulate a write failure. | 153 | * ubi_dbg_is_write_failure - if it is time to emulate a write failure. |
154 | * @ubi: UBI device description object | ||
152 | * | 155 | * |
153 | * Returns non-zero if a write failure should be emulated, otherwise returns | 156 | * Returns non-zero if a write failure should be emulated, otherwise returns |
154 | * zero. | 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 | if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES) | 161 | if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES) |
159 | return !(random32() % 500); | 162 | return !(random32() % 500); |
@@ -162,11 +165,12 @@ static inline int ubi_dbg_is_write_failure(void) | |||
162 | 165 | ||
163 | /** | 166 | /** |
164 | * ubi_dbg_is_erase_failure - if its time to emulate an erase failure. | 167 | * ubi_dbg_is_erase_failure - if its time to emulate an erase failure. |
168 | * @ubi: UBI device description object | ||
165 | * | 169 | * |
166 | * Returns non-zero if an erase failure should be emulated, otherwise returns | 170 | * Returns non-zero if an erase failure should be emulated, otherwise returns |
167 | * zero. | 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 | if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES) | 175 | if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES) |
172 | return !(random32() % 400); | 176 | return !(random32() % 400); |
@@ -233,10 +237,13 @@ static inline void ubi_debugfs_exit(void) { return; } | |||
233 | static inline int ubi_debugfs_init_dev(struct ubi_device *ubi) { return 0; } | 237 | static inline int ubi_debugfs_init_dev(struct ubi_device *ubi) { return 0; } |
234 | static inline void ubi_debugfs_exit_dev(struct ubi_device *ubi) { return; } | 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; } | 240 | static inline int |
237 | static inline int ubi_dbg_is_bitflip(void) { return 0; } | 241 | ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) { return 0; } |
238 | static inline int ubi_dbg_is_write_failure(void) { return 0; } | 242 | static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) { return 0; } |
239 | static inline int ubi_dbg_is_erase_failure(void) { 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 | #endif /* !CONFIG_MTD_UBI_DEBUG */ | 248 | #endif /* !CONFIG_MTD_UBI_DEBUG */ |
242 | #endif /* !__UBI_DEBUG_H__ */ | 249 | #endif /* !__UBI_DEBUG_H__ */ |
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index e23d6118224..6ba55c23587 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
@@ -212,7 +212,7 @@ retry: | |||
212 | } else { | 212 | } else { |
213 | ubi_assert(len == read); | 213 | ubi_assert(len == read); |
214 | 214 | ||
215 | if (ubi_dbg_is_bitflip()) { | 215 | if (ubi_dbg_is_bitflip(ubi)) { |
216 | dbg_gen("bit-flip (emulated)"); | 216 | dbg_gen("bit-flip (emulated)"); |
217 | err = UBI_IO_BITFLIPS; | 217 | err = UBI_IO_BITFLIPS; |
218 | } | 218 | } |
@@ -281,7 +281,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, | |||
281 | return err; | 281 | return err; |
282 | } | 282 | } |
283 | 283 | ||
284 | if (ubi_dbg_is_write_failure()) { | 284 | if (ubi_dbg_is_write_failure(ubi)) { |
285 | dbg_err("cannot write %d bytes to PEB %d:%d " | 285 | dbg_err("cannot write %d bytes to PEB %d:%d " |
286 | "(emulated)", len, pnum, offset); | 286 | "(emulated)", len, pnum, offset); |
287 | ubi_dbg_dump_stack(); | 287 | ubi_dbg_dump_stack(); |
@@ -396,7 +396,7 @@ retry: | |||
396 | if (err) | 396 | if (err) |
397 | return err; | 397 | return err; |
398 | 398 | ||
399 | if (ubi_dbg_is_erase_failure()) { | 399 | if (ubi_dbg_is_erase_failure(ubi)) { |
400 | dbg_err("cannot erase PEB %d (emulated)", pnum); | 400 | dbg_err("cannot erase PEB %d (emulated)", pnum); |
401 | return -EIO; | 401 | return -EIO; |
402 | } | 402 | } |
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index bf13ca275f8..42c684cf368 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
@@ -616,7 +616,7 @@ static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk) | |||
616 | list_add_tail(&wrk->list, &ubi->works); | 616 | list_add_tail(&wrk->list, &ubi->works); |
617 | ubi_assert(ubi->works_count >= 0); | 617 | ubi_assert(ubi->works_count >= 0); |
618 | ubi->works_count += 1; | 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 | wake_up_process(ubi->bgt_thread); | 620 | wake_up_process(ubi->bgt_thread); |
621 | spin_unlock(&ubi->wl_lock); | 621 | spin_unlock(&ubi->wl_lock); |
622 | } | 622 | } |
@@ -1367,7 +1367,7 @@ int ubi_thread(void *u) | |||
1367 | 1367 | ||
1368 | spin_lock(&ubi->wl_lock); | 1368 | spin_lock(&ubi->wl_lock); |
1369 | if (list_empty(&ubi->works) || ubi->ro_mode || | 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 | set_current_state(TASK_INTERRUPTIBLE); | 1371 | set_current_state(TASK_INTERRUPTIBLE); |
1372 | spin_unlock(&ubi->wl_lock); | 1372 | spin_unlock(&ubi->wl_lock); |
1373 | schedule(); | 1373 | schedule(); |