Lines Matching full:mtd

5  * Test OOB read and write on MTD device.
17 #include <linux/mtd/mtd.h>
27 MODULE_PARM_DESC(dev, "MTD device number to use");
31 static struct mtd_info *mtd; variable
61 loff_t addr = (loff_t)ebnum * mtd->erasesize; in write_eraseblock()
64 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { in write_eraseblock()
73 err = mtd_write_oob(mtd, addr, &ops); in write_eraseblock()
170 loff_t addr = (loff_t)ebnum * mtd->erasesize; in verify_eraseblock()
174 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { in verify_eraseblock()
183 err = mtd_read_oob(mtd, addr, &ops); in verify_eraseblock()
209 if (use_offset != 0 || use_len < mtd->oobavail) { in verify_eraseblock()
215 ops.ooblen = mtd->oobavail; in verify_eraseblock()
220 err = mtd_read_oob(mtd, addr, &ops); in verify_eraseblock()
224 if (err || ops.oobretlen != mtd->oobavail) { in verify_eraseblock()
241 mtd->oobavail - k); in verify_eraseblock()
265 loff_t addr = (loff_t)ebnum * mtd->erasesize; in verify_eraseblock_in_one_go()
266 size_t len = mtd->oobavail * pgcnt; in verify_eraseblock_in_one_go()
267 size_t oobavail = mtd->oobavail; in verify_eraseblock_in_one_go()
282 err = mtd_read_oob(mtd, addr, &ops); in verify_eraseblock_in_one_go()
294 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { in verify_eraseblock_in_one_go()
348 pr_info("Please specify a valid mtd-device via module parameter\n"); in mtd_oobtest_init()
349 pr_crit("CAREFUL: This test wipes all data on the specified MTD device!\n"); in mtd_oobtest_init()
353 pr_info("MTD device: %d\n", dev); in mtd_oobtest_init()
355 mtd = get_mtd_device(NULL, dev); in mtd_oobtest_init()
356 if (IS_ERR(mtd)) { in mtd_oobtest_init()
357 err = PTR_ERR(mtd); in mtd_oobtest_init()
358 pr_err("error: cannot get MTD device\n"); in mtd_oobtest_init()
362 if (!mtd_type_is_nand(mtd)) { in mtd_oobtest_init()
367 tmp = mtd->size; in mtd_oobtest_init()
368 do_div(tmp, mtd->erasesize); in mtd_oobtest_init()
370 pgcnt = mtd->erasesize / mtd->writesize; in mtd_oobtest_init()
372 pr_info("MTD device size %llu, eraseblock size %u, " in mtd_oobtest_init()
375 (unsigned long long)mtd->size, mtd->erasesize, in mtd_oobtest_init()
376 mtd->writesize, ebcnt, pgcnt, mtd->oobsize); in mtd_oobtest_init()
379 readbuf = kmalloc(mtd->erasesize, GFP_KERNEL); in mtd_oobtest_init()
382 writebuf = kmalloc(mtd->erasesize, GFP_KERNEL); in mtd_oobtest_init()
389 err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_oobtest_init()
394 use_len = mtd->oobavail; in mtd_oobtest_init()
395 use_len_max = mtd->oobavail; in mtd_oobtest_init()
401 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_oobtest_init()
421 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_oobtest_init()
454 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_oobtest_init()
460 use_len = mtd->oobavail; in mtd_oobtest_init()
461 use_len_max = mtd->oobavail; in mtd_oobtest_init()
471 use_len = mtd->oobavail; in mtd_oobtest_init()
472 use_len_max = mtd->oobavail; in mtd_oobtest_init()
480 use_len = mtd->oobavail; in mtd_oobtest_init()
481 use_len_max = mtd->oobavail; in mtd_oobtest_init()
487 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_oobtest_init()
493 addr0 += mtd->erasesize; in mtd_oobtest_init()
501 ops.ooboffs = mtd->oobavail; in mtd_oobtest_init()
506 err = mtd_write_oob(mtd, addr0, &ops); in mtd_oobtest_init()
520 ops.ooboffs = mtd->oobavail; in mtd_oobtest_init()
525 err = mtd_read_oob(mtd, addr0, &ops); in mtd_oobtest_init()
544 ops.ooblen = mtd->oobavail + 1; in mtd_oobtest_init()
551 err = mtd_write_oob(mtd, mtd->size - mtd->writesize, &ops); in mtd_oobtest_init()
563 ops.ooblen = mtd->oobavail + 1; in mtd_oobtest_init()
570 err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); in mtd_oobtest_init()
581 err = mtdtest_erase_eraseblock(mtd, ebcnt - 1); in mtd_oobtest_init()
589 ops.ooblen = mtd->oobavail; in mtd_oobtest_init()
596 err = mtd_write_oob(mtd, mtd->size - mtd->writesize, &ops); in mtd_oobtest_init()
608 ops.ooblen = mtd->oobavail; in mtd_oobtest_init()
615 err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); in mtd_oobtest_init()
631 err = mtdtest_erase_good_eraseblocks(mtd, bbt, 0, ebcnt); in mtd_oobtest_init()
641 size_t sz = mtd->oobavail; in mtd_oobtest_init()
644 addr = (loff_t)(i + 1) * mtd->erasesize - mtd->writesize; in mtd_oobtest_init()
655 err = mtd_write_oob(mtd, addr, &ops); in mtd_oobtest_init()
665 addr += mtd->writesize; in mtd_oobtest_init()
676 prandom_bytes_state(&rnd_state, writebuf, mtd->oobavail * 2); in mtd_oobtest_init()
677 addr = (loff_t)(i + 1) * mtd->erasesize - mtd->writesize; in mtd_oobtest_init()
681 ops.ooblen = mtd->oobavail * 2; in mtd_oobtest_init()
686 err = mtd_read_oob(mtd, addr, &ops); in mtd_oobtest_init()
693 mtd->oobavail * 2)) { in mtd_oobtest_init()
717 put_mtd_device(mtd); in mtd_oobtest_init()