Lines Matching full:mtd
5 * Test random reads, writes and erases on MTD device.
16 #include <linux/mtd/mtd.h>
26 MODULE_PARM_DESC(dev, "MTD device number to use");
32 static struct mtd_info *mtd; variable
82 if (offs >= mtd->erasesize) in do_read()
83 offs -= mtd->erasesize; in do_read()
84 if (offs + len > mtd->erasesize) in do_read()
85 len = mtd->erasesize - offs; in do_read()
87 addr = (loff_t)eb * mtd->erasesize + offs; in do_read()
88 return mtdtest_read(mtd, addr, len, readbuf); in do_read()
97 if (offs >= mtd->erasesize) { in do_write()
98 err = mtdtest_erase_eraseblock(mtd, eb); in do_write()
105 if (offs + len > mtd->erasesize) { in do_write()
107 len = mtd->erasesize - offs; in do_write()
109 err = mtdtest_erase_eraseblock(mtd, eb + 1); in do_write()
115 addr = (loff_t)eb * mtd->erasesize + offs; in do_write()
116 err = mtdtest_write(mtd, addr, len, writebuf); in do_write()
120 while (offs > mtd->erasesize) { in do_write()
121 offsets[eb++] = mtd->erasesize; in do_write()
122 offs -= mtd->erasesize; in do_write()
146 pr_info("Please specify a valid mtd-device via module parameter\n"); in mtd_stresstest_init()
147 pr_crit("CAREFUL: This test wipes all data on the specified MTD device!\n"); in mtd_stresstest_init()
151 pr_info("MTD device: %d\n", dev); in mtd_stresstest_init()
153 mtd = get_mtd_device(NULL, dev); in mtd_stresstest_init()
154 if (IS_ERR(mtd)) { in mtd_stresstest_init()
155 err = PTR_ERR(mtd); in mtd_stresstest_init()
156 pr_err("error: cannot get MTD device\n"); in mtd_stresstest_init()
160 if (mtd->writesize == 1) { in mtd_stresstest_init()
165 pgsize = mtd->writesize; in mtd_stresstest_init()
167 tmp = mtd->size; in mtd_stresstest_init()
168 do_div(tmp, mtd->erasesize); in mtd_stresstest_init()
170 pgcnt = mtd->erasesize / pgsize; in mtd_stresstest_init()
172 pr_info("MTD device size %llu, eraseblock size %u, " in mtd_stresstest_init()
175 (unsigned long long)mtd->size, mtd->erasesize, in mtd_stresstest_init()
176 pgsize, ebcnt, pgcnt, mtd->oobsize); in mtd_stresstest_init()
185 bufsize = mtd->erasesize * 2; in mtd_stresstest_init()
194 offsets[i] = mtd->erasesize; in mtd_stresstest_init()
200 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_stresstest_init()
225 put_mtd_device(mtd); in mtd_stresstest_init()