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
73 if (offs >= mtd->erasesize) in do_read()
74 offs -= mtd->erasesize; in do_read()
75 if (offs + len > mtd->erasesize) in do_read()
76 len = mtd->erasesize - offs; in do_read()
78 addr = (loff_t)eb * mtd->erasesize + offs; in do_read()
79 return mtdtest_read(mtd, addr, len, readbuf); in do_read()
88 if (offs >= mtd->erasesize) { in do_write()
89 err = mtdtest_erase_eraseblock(mtd, eb); in do_write()
96 if (offs + len > mtd->erasesize) { in do_write()
98 len = mtd->erasesize - offs; in do_write()
100 err = mtdtest_erase_eraseblock(mtd, eb + 1); in do_write()
106 addr = (loff_t)eb * mtd->erasesize + offs; in do_write()
107 err = mtdtest_write(mtd, addr, len, writebuf); in do_write()
111 while (offs > mtd->erasesize) { in do_write()
112 offsets[eb++] = mtd->erasesize; in do_write()
113 offs -= mtd->erasesize; in do_write()
137 pr_info("Please specify a valid mtd-device via module parameter\n"); in mtd_stresstest_init()
138 pr_crit("CAREFUL: This test wipes all data on the specified MTD device!\n"); in mtd_stresstest_init()
142 pr_info("MTD device: %d\n", dev); in mtd_stresstest_init()
144 mtd = get_mtd_device(NULL, dev); in mtd_stresstest_init()
145 if (IS_ERR(mtd)) { in mtd_stresstest_init()
146 err = PTR_ERR(mtd); in mtd_stresstest_init()
147 pr_err("error: cannot get MTD device\n"); in mtd_stresstest_init()
151 if (mtd->writesize == 1) { in mtd_stresstest_init()
156 pgsize = mtd->writesize; in mtd_stresstest_init()
158 tmp = mtd->size; in mtd_stresstest_init()
159 do_div(tmp, mtd->erasesize); in mtd_stresstest_init()
161 pgcnt = mtd->erasesize / pgsize; in mtd_stresstest_init()
163 pr_info("MTD device size %llu, eraseblock size %u, " in mtd_stresstest_init()
166 (unsigned long long)mtd->size, mtd->erasesize, in mtd_stresstest_init()
167 pgsize, ebcnt, pgcnt, mtd->oobsize); in mtd_stresstest_init()
176 bufsize = mtd->erasesize * 2; in mtd_stresstest_init()
185 offsets[i] = mtd->erasesize; in mtd_stresstest_init()
191 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_stresstest_init()
216 put_mtd_device(mtd); in mtd_stresstest_init()