mtd: tests: fix read, speed and stress tests on NOR flash
authorMorten Thunberg Svendsen <mts.doredevelopment@gmail.com>
Wed, 6 Jan 2010 09:48:18 +0000 (10:48 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 13 Jan 2010 09:06:17 +0000 (09:06 +0000)
Before using block_isbad() check if mtd->block_isbad() is defined.
Calculating pgcnt must be done using pgsize defined to 512 on
NOR and mtd->writesize for NAND, not using  mtd->writesize directly.

Signed-off-by: Morten Thunberg Svendsen <mts.doredevelopment@gmail.com>
Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/tests/mtd_readtest.c
drivers/mtd/tests/mtd_speedtest.c
drivers/mtd/tests/mtd_stresstest.c

index 79fc4530987b0fe49fda701d567569e7c44b9d85..25c5dd03a8373c93a692578ffb1a0724dcd2b33e 100644 (file)
@@ -147,6 +147,10 @@ static int scan_for_bad_eraseblocks(void)
        }
        memset(bbt, 0 , ebcnt);
 
+       /* NOR flash does not implement block_isbad */
+       if (mtd->block_isbad == NULL)
+               return 0;
+
        printk(PRINT_PREF "scanning for bad eraseblocks\n");
        for (i = 0; i < ebcnt; ++i) {
                bbt[i] = is_block_bad(i) ? 1 : 0;
@@ -184,7 +188,7 @@ static int __init mtd_readtest_init(void)
        tmp = mtd->size;
        do_div(tmp, mtd->erasesize);
        ebcnt = tmp;
-       pgcnt = mtd->erasesize / mtd->writesize;
+       pgcnt = mtd->erasesize / pgsize;
 
        printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
               "page size %u, count of eraseblocks %u, pages per "
index 141363a7e805f91976a2bc9db8030674baece709..7fbb51d4eabec7897811265d0fba5ee0e2ee1369 100644 (file)
@@ -301,6 +301,10 @@ static int scan_for_bad_eraseblocks(void)
        }
        memset(bbt, 0 , ebcnt);
 
+       /* NOR flash does not implement block_isbad */
+       if (mtd->block_isbad == NULL)
+               goto out;
+
        printk(PRINT_PREF "scanning for bad eraseblocks\n");
        for (i = 0; i < ebcnt; ++i) {
                bbt[i] = is_block_bad(i) ? 1 : 0;
@@ -309,6 +313,7 @@ static int scan_for_bad_eraseblocks(void)
                cond_resched();
        }
        printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
+out:
        goodebcnt = ebcnt - bad;
        return 0;
 }
@@ -340,7 +345,7 @@ static int __init mtd_speedtest_init(void)
        tmp = mtd->size;
        do_div(tmp, mtd->erasesize);
        ebcnt = tmp;
-       pgcnt = mtd->erasesize / mtd->writesize;
+       pgcnt = mtd->erasesize / pgsize;
 
        printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
               "page size %u, count of eraseblocks %u, pages per "
index 63920476b57a24c7e61563303eb3abb773b73fdf..a99d3cd737d82caf30ffcce266bebdd56fa9e0f5 100644 (file)
@@ -227,6 +227,10 @@ static int scan_for_bad_eraseblocks(void)
        }
        memset(bbt, 0 , ebcnt);
 
+       /* NOR flash does not implement block_isbad */
+       if (mtd->block_isbad == NULL)
+               return 0;
+
        printk(PRINT_PREF "scanning for bad eraseblocks\n");
        for (i = 0; i < ebcnt; ++i) {
                bbt[i] = is_block_bad(i) ? 1 : 0;
@@ -265,7 +269,7 @@ static int __init mtd_stresstest_init(void)
        tmp = mtd->size;
        do_div(tmp, mtd->erasesize);
        ebcnt = tmp;
-       pgcnt = mtd->erasesize / mtd->writesize;
+       pgcnt = mtd->erasesize / pgsize;
 
        printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
               "page size %u, count of eraseblocks %u, pages per "