aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/tests
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-08-03 05:52:15 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-08-30 16:34:24 -0400
commit6cf78358c94fc30cc1fe93992b67060302a2457e (patch)
tree6c8bf2c7b843caea4c65ea1a041e0d17aeca0325 /drivers/mtd/tests
parent725cd71c0245d1ac7e4441799e2d32fe4b68be8f (diff)
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>
Diffstat (limited to 'drivers/mtd/tests')
-rw-r--r--drivers/mtd/tests/torturetest.c66
1 files changed, 7 insertions, 59 deletions
diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c
index 3a9f6a6a79f9..eeab96973cf0 100644
--- a/drivers/mtd/tests/torturetest.c
+++ b/drivers/mtd/tests/torturetest.c
@@ -32,6 +32,7 @@
32#include <linux/mtd/mtd.h> 32#include <linux/mtd/mtd.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include "mtd_test.h"
35 36
36#define RETRIES 3 37#define RETRIES 3
37 38
@@ -93,35 +94,6 @@ static inline void stop_timing(void)
93} 94}
94 95
95/* 96/*
96 * Erase eraseblock number @ebnum.
97 */
98static 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 * Check that the contents of eraseblock number @enbum is equivalent to the 97 * Check that the contents of eraseblock number @enbum is equivalent to the
126 * @buf buffer. 98 * @buf buffer.
127 */ 99 */
@@ -208,7 +180,7 @@ static inline int write_pattern(int ebnum, void *buf)
208static int __init tort_init(void) 180static int __init tort_init(void)
209{ 181{
210 int err = 0, i, infinite = !cycles_count; 182 int err = 0, i, infinite = !cycles_count;
211 int *bad_ebs; 183 unsigned char *bad_ebs;
212 184
213 printk(KERN_INFO "\n"); 185 printk(KERN_INFO "\n");
214 printk(KERN_INFO "=================================================\n"); 186 printk(KERN_INFO "=================================================\n");
@@ -265,7 +237,7 @@ static int __init tort_init(void)
265 if (!check_buf) 237 if (!check_buf)
266 goto out_patt_FF; 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 if (!bad_ebs) 241 if (!bad_ebs)
270 goto out_check_buf; 242 goto out_check_buf;
271 243
@@ -283,40 +255,16 @@ static int __init tort_init(void)
283 } 255 }
284 } 256 }
285 257
286 /* 258 err = mtdtest_scan_for_bad_eraseblocks(mtd, bad_ebs, eb, ebcnt);
287 * Check if there is a bad eraseblock among those we are going to test. 259 if (err)
288 */ 260 goto out;
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);
292
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 261
306 start_timing(); 262 start_timing();
307 while (1) { 263 while (1) {
308 int i; 264 int i;
309 void *patt; 265 void *patt;
310 266
311 /* Erase all eraseblocks */ 267 mtdtest_erase_good_eraseblocks(mtd, bad_ebs, eb, ebcnt);
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 }
320 268
321 /* Check if the eraseblocks contain only 0xFF bytes */ 269 /* Check if the eraseblocks contain only 0xFF bytes */
322 if (check) { 270 if (check) {