Commit 6cf78358c94fc30cc1fe93992b67060302a2457e
Committed by
David Woodhouse
1 parent
725cd71c02
Exists in
master
and in
20 other branches
mtd: mtd_torturetest: use mtd_test helpers
Use mtdtest_scan_for_bad_eraseblocks() and mtdtest_erase_good_eraseblocks() in mtd_test helpers. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Brian Norris <computersforpeace@gmail.com> Cc: Vikram Narayanan <vikram186@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Showing 1 changed file with 7 additions and 59 deletions Side-by-side Diff
drivers/mtd/tests/torturetest.c
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | #include <linux/mtd/mtd.h> |
33 | 33 | #include <linux/slab.h> |
34 | 34 | #include <linux/sched.h> |
35 | +#include "mtd_test.h" | |
35 | 36 | |
36 | 37 | #define RETRIES 3 |
37 | 38 | |
... | ... | @@ -93,35 +94,6 @@ |
93 | 94 | } |
94 | 95 | |
95 | 96 | /* |
96 | - * Erase eraseblock number @ebnum. | |
97 | - */ | |
98 | -static inline int erase_eraseblock(int ebnum) | |
99 | -{ | |
100 | - int err; | |
101 | - struct erase_info ei; | |
102 | - loff_t addr = ebnum * mtd->erasesize; | |
103 | - | |
104 | - memset(&ei, 0, sizeof(struct erase_info)); | |
105 | - ei.mtd = mtd; | |
106 | - ei.addr = addr; | |
107 | - ei.len = mtd->erasesize; | |
108 | - | |
109 | - err = mtd_erase(mtd, &ei); | |
110 | - if (err) { | |
111 | - pr_err("error %d while erasing EB %d\n", err, ebnum); | |
112 | - return err; | |
113 | - } | |
114 | - | |
115 | - if (ei.state == MTD_ERASE_FAILED) { | |
116 | - pr_err("some erase error occurred at EB %d\n", | |
117 | - ebnum); | |
118 | - return -EIO; | |
119 | - } | |
120 | - | |
121 | - return 0; | |
122 | -} | |
123 | - | |
124 | -/* | |
125 | 97 | * Check that the contents of eraseblock number @enbum is equivalent to the |
126 | 98 | * @buf buffer. |
127 | 99 | */ |
... | ... | @@ -208,7 +180,7 @@ |
208 | 180 | static int __init tort_init(void) |
209 | 181 | { |
210 | 182 | int err = 0, i, infinite = !cycles_count; |
211 | - int *bad_ebs; | |
183 | + unsigned char *bad_ebs; | |
212 | 184 | |
213 | 185 | printk(KERN_INFO "\n"); |
214 | 186 | printk(KERN_INFO "=================================================\n"); |
... | ... | @@ -265,7 +237,7 @@ |
265 | 237 | if (!check_buf) |
266 | 238 | goto out_patt_FF; |
267 | 239 | |
268 | - bad_ebs = kcalloc(ebcnt, sizeof(*bad_ebs), GFP_KERNEL); | |
240 | + bad_ebs = kzalloc(ebcnt, GFP_KERNEL); | |
269 | 241 | if (!bad_ebs) |
270 | 242 | goto out_check_buf; |
271 | 243 | |
272 | 244 | |
273 | 245 | |
... | ... | @@ -283,40 +255,16 @@ |
283 | 255 | } |
284 | 256 | } |
285 | 257 | |
286 | - /* | |
287 | - * Check if there is a bad eraseblock among those we are going to test. | |
288 | - */ | |
289 | - if (mtd_can_have_bb(mtd)) { | |
290 | - for (i = eb; i < eb + ebcnt; i++) { | |
291 | - err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize); | |
258 | + err = mtdtest_scan_for_bad_eraseblocks(mtd, bad_ebs, eb, ebcnt); | |
259 | + if (err) | |
260 | + goto out; | |
292 | 261 | |
293 | - if (err < 0) { | |
294 | - pr_info("block_isbad() returned %d " | |
295 | - "for EB %d\n", err, i); | |
296 | - goto out; | |
297 | - } | |
298 | - | |
299 | - if (err) { | |
300 | - pr_err("EB %d is bad. Skip it.\n", i); | |
301 | - bad_ebs[i - eb] = 1; | |
302 | - } | |
303 | - } | |
304 | - } | |
305 | - | |
306 | 262 | start_timing(); |
307 | 263 | while (1) { |
308 | 264 | int i; |
309 | 265 | void *patt; |
310 | 266 | |
311 | - /* Erase all eraseblocks */ | |
312 | - for (i = eb; i < eb + ebcnt; i++) { | |
313 | - if (bad_ebs[i - eb]) | |
314 | - continue; | |
315 | - err = erase_eraseblock(i); | |
316 | - if (err) | |
317 | - goto out; | |
318 | - cond_resched(); | |
319 | - } | |
267 | + mtdtest_erase_good_eraseblocks(mtd, bad_ebs, eb, ebcnt); | |
320 | 268 | |
321 | 269 | /* Check if the eraseblocks contain only 0xFF bytes */ |
322 | 270 | if (check) { |
-
mentioned in commit b9c257
-
mentioned in commit b9c257
-
mentioned in commit b9c257
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298
-
mentioned in commit 68f298