Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
[safe/jmp/linux-2.6] / drivers / mtd / tests / mtd_speedtest.c
index 141363a..161feeb 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_speedtest: "
@@ -294,12 +295,15 @@ static int scan_for_bad_eraseblocks(void)
 {
        int i, bad = 0;
 
-       bbt = kmalloc(ebcnt, GFP_KERNEL);
+       bbt = kzalloc(ebcnt, GFP_KERNEL);
        if (!bbt) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       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) {
@@ -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 "