Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f54d6336 authored by Akinobu Mita's avatar Akinobu Mita Committed by David Woodhouse
Browse files

mtd: cleanup mtd_oobtest



- Remove unnecessary memset for bbt
  All entries will be initialized at a few lines below
- Remove unnecessary initialization for mtd->erasesize
- Use write_whole_device()

Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 5a134239
Loading
Loading
Loading
Loading
+4 −14
Original line number Original line Diff line number Diff line
@@ -343,7 +343,6 @@ static int scan_for_bad_eraseblocks(void)
		printk(PRINT_PREF "error: cannot allocate memory\n");
		printk(PRINT_PREF "error: cannot allocate memory\n");
		return -ENOMEM;
		return -ENOMEM;
	}
	}
	memset(bbt, 0 , ebcnt);


	printk(PRINT_PREF "scanning for bad eraseblocks\n");
	printk(PRINT_PREF "scanning for bad eraseblocks\n");
	for (i = 0; i < ebcnt; ++i) {
	for (i = 0; i < ebcnt; ++i) {
@@ -392,7 +391,6 @@ static int __init mtd_oobtest_init(void)
	       mtd->writesize, ebcnt, pgcnt, mtd->oobsize);
	       mtd->writesize, ebcnt, pgcnt, mtd->oobsize);


	err = -ENOMEM;
	err = -ENOMEM;
	mtd->erasesize = mtd->erasesize;
	readbuf = kmalloc(mtd->erasesize, GFP_KERNEL);
	readbuf = kmalloc(mtd->erasesize, GFP_KERNEL);
	if (!readbuf) {
	if (!readbuf) {
		printk(PRINT_PREF "error: cannot allocate memory\n");
		printk(PRINT_PREF "error: cannot allocate memory\n");
@@ -476,18 +474,10 @@ static int __init mtd_oobtest_init(void)
	use_len_max = mtd->ecclayout->oobavail;
	use_len_max = mtd->ecclayout->oobavail;
	vary_offset = 1;
	vary_offset = 1;
	simple_srand(5);
	simple_srand(5);
	printk(PRINT_PREF "writing OOBs of whole device\n");

	for (i = 0; i < ebcnt; ++i) {
	err = write_whole_device();
		if (bbt[i])
			continue;
		err = write_eraseblock(i);
	if (err)
	if (err)
		goto out;
		goto out;
		if (i % 256 == 0)
			printk(PRINT_PREF "written up to eraseblock %u\n", i);
		cond_resched();
	}
	printk(PRINT_PREF "written %u eraseblocks\n", i);


	/* Check all eraseblocks */
	/* Check all eraseblocks */
	use_offset = 0;
	use_offset = 0;