* [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules
@ 2013-07-27 2:14 Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 1/7] mtd: tests: introduce mtd_test module Akinobu Mita
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
This patch set reduces code duplication among mtd/tests modules by
moving common helper functions into mtd_test module.
Akinobu Mita (7):
mtd: tests: introduce mtd_test module
mtd: mtd_oobtest: use mtd_test module
mtd: mtd_pagetest: use mtd_test module
mtd: mtd_readtest: use mtd_test module
mtd: mtd_speedtest: use mtd_test module
mtd: mtd_stresstest: use mtd_test module
mtd: mtd_subpagetest: use mtd_test module
drivers/mtd/tests/Makefile | 1 +
drivers/mtd/tests/mtd_oobtest.c | 92 +++--------------
drivers/mtd/tests/mtd_pagetest.c | 199 ++++++++++--------------------------
drivers/mtd/tests/mtd_readtest.c | 51 ++-------
drivers/mtd/tests/mtd_speedtest.c | 180 +++++++-------------------------
drivers/mtd/tests/mtd_stresstest.c | 86 +++-------------
drivers/mtd/tests/mtd_subpagetest.c | 87 ++--------------
drivers/mtd/tests/mtd_test.c | 117 +++++++++++++++++++++
drivers/mtd/tests/mtd_test.h | 11 ++
9 files changed, 262 insertions(+), 562 deletions(-)
create mode 100644 drivers/mtd/tests/mtd_test.c
create mode 100644 drivers/mtd/tests/mtd_test.h
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
--
1.8.3.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
2013-07-27 19:27 ` Brian Norris
2013-07-27 2:14 ` [PATCH -next 2/7] mtd: mtd_oobtest: use " Akinobu Mita
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
This introduces mtd_test module which contains the following functions
used by several mtd/tests modules.
- mtdtest_erase_eraseblock()
- mtdtest_scan_for_bad_eraseblocks()
- mtdtest_erase_whole_device()
This mtd_test module also provides the following wrapper functions for
mtd_read() and mtd_write() in order to simplify the return value check
in mtd/tests modules.
- mtdtest_read()
- mtdtest_write()
These functions will be used for reducing code duplication among
mtd/tests modules later.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/Makefile | 1 +
drivers/mtd/tests/mtd_test.c | 117 +++++++++++++++++++++++++++++++++++++++++++
drivers/mtd/tests/mtd_test.h | 11 ++++
3 files changed, 129 insertions(+)
create mode 100644 drivers/mtd/tests/mtd_test.c
create mode 100644 drivers/mtd/tests/mtd_test.h
diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile
index bd0065c..3d642f4 100644
--- a/drivers/mtd/tests/Makefile
+++ b/drivers/mtd/tests/Makefile
@@ -1,3 +1,4 @@
+obj-$(CONFIG_MTD_TESTS) += mtd_test.o
obj-$(CONFIG_MTD_TESTS) += mtd_oobtest.o
obj-$(CONFIG_MTD_TESTS) += mtd_pagetest.o
obj-$(CONFIG_MTD_TESTS) += mtd_readtest.o
diff --git a/drivers/mtd/tests/mtd_test.c b/drivers/mtd/tests/mtd_test.c
new file mode 100644
index 0000000..1fa1d63
--- /dev/null
+++ b/drivers/mtd/tests/mtd_test.c
@@ -0,0 +1,117 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/printk.h>
+
+#include "mtd_test.h"
+
+int mtdtest_erase_eraseblock(struct mtd_info *mtd, int ebnum)
+{
+ int err;
+ struct erase_info ei;
+ loff_t addr = ebnum * mtd->erasesize;
+
+ memset(&ei, 0, sizeof(struct erase_info));
+ ei.mtd = mtd;
+ ei.addr = addr;
+ ei.len = mtd->erasesize;
+
+ err = mtd_erase(mtd, &ei);
+ if (err) {
+ pr_info("error %d while erasing EB %d\n", err, ebnum);
+ return err;
+ }
+
+ if (ei.state == MTD_ERASE_FAILED) {
+ pr_info("some erase error occurred at EB %d\n", ebnum);
+ return -EIO;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mtdtest_erase_eraseblock);
+
+static int is_block_bad(struct mtd_info *mtd, int ebnum)
+{
+ int ret;
+ loff_t addr = ebnum * mtd->erasesize;
+
+ ret = mtd_block_isbad(mtd, addr);
+ if (ret)
+ pr_info("block %d is bad\n", ebnum);
+
+ return ret;
+}
+
+int mtdtest_scan_for_bad_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
+ int ebcnt)
+{
+ int i, bad = 0;
+
+ if (!mtd_can_have_bb(mtd))
+ return 0;
+
+ pr_info("scanning for bad eraseblocks\n");
+ for (i = 0; i < ebcnt; ++i) {
+ bbt[i] = is_block_bad(mtd, i) ? 1 : 0;
+ if (bbt[i])
+ bad += 1;
+ cond_resched();
+ }
+ pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mtdtest_scan_for_bad_eraseblocks);
+
+int mtdtest_erase_whole_device(struct mtd_info *mtd, unsigned char *bbt,
+ int ebcnt)
+{
+ int err;
+ unsigned int i;
+
+ for (i = 0; i < ebcnt; ++i) {
+ if (bbt[i])
+ continue;
+ err = mtdtest_erase_eraseblock(mtd, i);
+ if (err)
+ return err;
+ cond_resched();
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mtdtest_erase_whole_device);
+
+int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf)
+{
+ size_t read;
+ int err;
+
+ err = mtd_read(mtd, addr, size, &read, buf);
+ /* Ignore corrected ECC errors */
+ if (mtd_is_bitflip(err))
+ err = 0;
+ if (!err && read != size)
+ err = -EINVAL;
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(mtdtest_read);
+
+int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size,
+ const void *buf)
+{
+ size_t written;
+ int err;
+
+ err = mtd_write(mtd, addr, size, &written, buf);
+ if (!err && written != size)
+ err = -EIO;
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(mtdtest_write);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_test.h b/drivers/mtd/tests/mtd_test.h
new file mode 100644
index 0000000..e61fb67
--- /dev/null
+++ b/drivers/mtd/tests/mtd_test.h
@@ -0,0 +1,11 @@
+#include <linux/mtd/mtd.h>
+
+int mtdtest_erase_eraseblock(struct mtd_info *mtd, int ebnum);
+int mtdtest_scan_for_bad_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
+ int ebcnt);
+int mtdtest_erase_whole_device(struct mtd_info *mtd, unsigned char *bbt,
+ int ebcnt);
+
+int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf);
+int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size,
+ const void *buf);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 2/7] mtd: mtd_oobtest: use mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 1/7] mtd: tests: introduce mtd_test module Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 3/7] mtd: mtd_pagetest: " Akinobu Mita
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
Use mtdtest_scan_for_bad_eraseblocks(), mtdtest_erase_whole_device(),
and mtdtest_erase_eraseblock() in mtd_test module.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/mtd_oobtest.c | 92 ++++++-----------------------------------
1 file changed, 12 insertions(+), 80 deletions(-)
diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
index ab81e9a..8d5e35c 100644
--- a/drivers/mtd/tests/mtd_oobtest.c
+++ b/drivers/mtd/tests/mtd_oobtest.c
@@ -31,6 +31,8 @@
#include <linux/sched.h>
#include <linux/random.h>
+#include "mtd_test.h"
+
static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -49,49 +51,6 @@ static int use_len_max;
static int vary_offset;
static struct rnd_state rnd_state;
-static int erase_eraseblock(int ebnum)
-{
- int err;
- struct erase_info ei;
- loff_t addr = ebnum * mtd->erasesize;
-
- memset(&ei, 0, sizeof(struct erase_info));
- ei.mtd = mtd;
- ei.addr = addr;
- ei.len = mtd->erasesize;
-
- err = mtd_erase(mtd, &ei);
- if (err) {
- pr_err("error %d while erasing EB %d\n", err, ebnum);
- return err;
- }
-
- if (ei.state == MTD_ERASE_FAILED) {
- pr_err("some erase error occurred at EB %d\n", ebnum);
- return -EIO;
- }
-
- return 0;
-}
-
-static int erase_whole_device(void)
-{
- int err;
- unsigned int i;
-
- pr_info("erasing whole device\n");
- for (i = 0; i < ebcnt; ++i) {
- if (bbt[i])
- continue;
- err = erase_eraseblock(i);
- if (err)
- return err;
- cond_resched();
- }
- pr_info("erased %u eraseblocks\n", i);
- return 0;
-}
-
static void do_vary_offset(void)
{
use_len -= 1;
@@ -304,36 +263,6 @@ static int verify_all_eraseblocks(void)
return 0;
}
-static int is_block_bad(int ebnum)
-{
- int ret;
- loff_t addr = ebnum * mtd->erasesize;
-
- ret = mtd_block_isbad(mtd, addr);
- if (ret)
- pr_info("block %d is bad\n", ebnum);
- return ret;
-}
-
-static int scan_for_bad_eraseblocks(void)
-{
- int i, bad = 0;
-
- bbt = kmalloc(ebcnt, GFP_KERNEL);
- if (!bbt)
- return -ENOMEM;
-
- pr_info("scanning for bad eraseblocks\n");
- for (i = 0; i < ebcnt; ++i) {
- bbt[i] = is_block_bad(i) ? 1 : 0;
- if (bbt[i])
- bad += 1;
- cond_resched();
- }
- pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
- return 0;
-}
-
static int __init mtd_oobtest_init(void)
{
int err = 0;
@@ -383,8 +312,11 @@ static int __init mtd_oobtest_init(void)
writebuf = kmalloc(mtd->erasesize, GFP_KERNEL);
if (!writebuf)
goto out;
+ bbt = kzalloc(ebcnt, GFP_KERNEL);
+ if (!bbt)
+ goto out;
- err = scan_for_bad_eraseblocks();
+ err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -396,7 +328,7 @@ static int __init mtd_oobtest_init(void)
/* First test: write all OOB, read it back and verify */
pr_info("test 1 of 5\n");
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -416,7 +348,7 @@ static int __init mtd_oobtest_init(void)
*/
pr_info("test 2 of 5\n");
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -446,7 +378,7 @@ static int __init mtd_oobtest_init(void)
*/
pr_info("test 3 of 5\n");
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -479,7 +411,7 @@ static int __init mtd_oobtest_init(void)
/* Fourth test: try to write off end of device */
pr_info("test 4 of 5\n");
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -571,7 +503,7 @@ static int __init mtd_oobtest_init(void)
errcnt += 1;
}
- err = erase_eraseblock(ebcnt - 1);
+ err = mtdtest_erase_eraseblock(mtd, ebcnt - 1);
if (err)
goto out;
@@ -620,7 +552,7 @@ static int __init mtd_oobtest_init(void)
pr_info("test 5 of 5\n");
/* Erase all eraseblocks */
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 3/7] mtd: mtd_pagetest: use mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 1/7] mtd: tests: introduce mtd_test module Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 2/7] mtd: mtd_oobtest: use " Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 4/7] mtd: mtd_readtest: " Akinobu Mita
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
Use mtdtest_write(), mtdtest_read(), mtdtest_erase_eraseblock(),
mtdtest_scan_for_bad_eraseblocks(), and mtdtest_erase_whole_device()
in mtd_test module.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/mtd_pagetest.c | 199 +++++++++++----------------------------
1 file changed, 55 insertions(+), 144 deletions(-)
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index acd991f..87a8ee9 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -31,6 +31,8 @@
#include <linux/sched.h>
#include <linux/random.h>
+#include "mtd_test.h"
+
static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -48,42 +50,15 @@ static int pgcnt;
static int errcnt;
static struct rnd_state rnd_state;
-static int erase_eraseblock(int ebnum)
-{
- int err;
- struct erase_info ei;
- loff_t addr = ebnum * mtd->erasesize;
-
- memset(&ei, 0, sizeof(struct erase_info));
- ei.mtd = mtd;
- ei.addr = addr;
- ei.len = mtd->erasesize;
-
- err = mtd_erase(mtd, &ei);
- if (err) {
- pr_err("error %d while erasing EB %d\n", err, ebnum);
- return err;
- }
-
- if (ei.state == MTD_ERASE_FAILED) {
- pr_err("some erase error occurred at EB %d\n",
- ebnum);
- return -EIO;
- }
-
- return 0;
-}
-
static int write_eraseblock(int ebnum)
{
- int err = 0;
- size_t written;
+ int err;
loff_t addr = ebnum * mtd->erasesize;
prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize);
cond_resched();
- err = mtd_write(mtd, addr, mtd->erasesize, &written, writebuf);
- if (err || written != mtd->erasesize)
+ err = mtdtest_write(mtd, addr, mtd->erasesize, writebuf);
+ if (err)
pr_err("error: write failed at %#llx\n",
(long long)addr);
@@ -93,7 +68,6 @@ static int write_eraseblock(int ebnum)
static int verify_eraseblock(int ebnum)
{
uint32_t j;
- size_t read;
int err = 0, i;
loff_t addr0, addrn;
loff_t addr = ebnum * mtd->erasesize;
@@ -109,27 +83,21 @@ static int verify_eraseblock(int ebnum)
prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize);
for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) {
/* Do a read to set the internal dataRAMs to different data */
- err = mtd_read(mtd, addr0, bufsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != bufsize) {
+ err = mtdtest_read(mtd, addr0, bufsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr0);
return err;
}
- err = mtd_read(mtd, addrn - bufsize, bufsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != bufsize) {
+ err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)(addrn - bufsize));
return err;
}
memset(twopages, 0, bufsize);
- err = mtd_read(mtd, addr, bufsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != bufsize) {
+ err = mtdtest_read(mtd, addr, bufsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
break;
@@ -145,27 +113,21 @@ static int verify_eraseblock(int ebnum)
struct rnd_state old_state = rnd_state;
/* Do a read to set the internal dataRAMs to different data */
- err = mtd_read(mtd, addr0, bufsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != bufsize) {
+ err = mtdtest_read(mtd, addr0, bufsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr0);
return err;
}
- err = mtd_read(mtd, addrn - bufsize, bufsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != bufsize) {
+ err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)(addrn - bufsize));
return err;
}
memset(twopages, 0, bufsize);
- err = mtd_read(mtd, addr, bufsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != bufsize) {
+ err = mtdtest_read(mtd, addr, bufsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
return err;
@@ -184,7 +146,6 @@ static int verify_eraseblock(int ebnum)
static int crosstest(void)
{
- size_t read;
int err = 0, i;
loff_t addr, addr0, addrn;
unsigned char *pp1, *pp2, *pp3, *pp4;
@@ -208,10 +169,8 @@ static int crosstest(void)
/* Read 2nd-to-last page to pp1 */
addr = addrn - pgsize - pgsize;
- err = mtd_read(mtd, addr, pgsize, &read, pp1);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, pp1);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
kfree(pp1);
@@ -220,10 +179,8 @@ static int crosstest(void)
/* Read 3rd-to-last page to pp1 */
addr = addrn - pgsize - pgsize - pgsize;
- err = mtd_read(mtd, addr, pgsize, &read, pp1);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, pp1);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
kfree(pp1);
@@ -233,10 +190,8 @@ static int crosstest(void)
/* Read first page to pp2 */
addr = addr0;
pr_info("reading page at %#llx\n", (long long)addr);
- err = mtd_read(mtd, addr, pgsize, &read, pp2);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, pp2);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
kfree(pp1);
@@ -246,10 +201,8 @@ static int crosstest(void)
/* Read last page to pp3 */
addr = addrn - pgsize;
pr_info("reading page at %#llx\n", (long long)addr);
- err = mtd_read(mtd, addr, pgsize, &read, pp3);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, pp3);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
kfree(pp1);
@@ -259,10 +212,8 @@ static int crosstest(void)
/* Read first page again to pp4 */
addr = addr0;
pr_info("reading page at %#llx\n", (long long)addr);
- err = mtd_read(mtd, addr, pgsize, &read, pp4);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, pp4);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
kfree(pp1);
@@ -283,7 +234,6 @@ static int crosstest(void)
static int erasecrosstest(void)
{
- size_t read, written;
int err = 0, i, ebnum, ebnum2;
loff_t addr0;
char *readbuf = twopages;
@@ -302,26 +252,24 @@ static int erasecrosstest(void)
ebnum2 -= 1;
pr_info("erasing block %d\n", ebnum);
- err = erase_eraseblock(ebnum);
+ err = mtdtest_erase_eraseblock(mtd, ebnum);
if (err)
return err;
pr_info("writing 1st page of block %d\n", ebnum);
prandom_bytes_state(&rnd_state, writebuf, pgsize);
strcpy(writebuf, "There is no data like this!");
- err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
- if (err || written != pgsize) {
+ err = mtdtest_write(mtd, addr0, pgsize, writebuf);
+ if (err) {
pr_info("error: write failed at %#llx\n",
(long long)addr0);
- return err ? err : -1;
+ return err;
}
pr_info("reading 1st page of block %d\n", ebnum);
memset(readbuf, 0, pgsize);
- err = mtd_read(mtd, addr0, pgsize, &read, readbuf);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr0, pgsize, readbuf);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr0);
return err ? err : -1;
@@ -335,31 +283,29 @@ static int erasecrosstest(void)
}
pr_info("erasing block %d\n", ebnum);
- err = erase_eraseblock(ebnum);
+ err = mtdtest_erase_eraseblock(mtd, ebnum);
if (err)
return err;
pr_info("writing 1st page of block %d\n", ebnum);
prandom_bytes_state(&rnd_state, writebuf, pgsize);
strcpy(writebuf, "There is no data like this!");
- err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
- if (err || written != pgsize) {
+ err = mtdtest_write(mtd, addr0, pgsize, writebuf);
+ if (err) {
pr_err("error: write failed at %#llx\n",
(long long)addr0);
- return err ? err : -1;
+ return err;
}
pr_info("erasing block %d\n", ebnum2);
- err = erase_eraseblock(ebnum2);
+ err = mtdtest_erase_eraseblock(mtd, ebnum2);
if (err)
return err;
pr_info("reading 1st page of block %d\n", ebnum);
memset(readbuf, 0, pgsize);
- err = mtd_read(mtd, addr0, pgsize, &read, readbuf);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr0, pgsize, readbuf);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr0);
return err ? err : -1;
@@ -379,7 +325,6 @@ static int erasecrosstest(void)
static int erasetest(void)
{
- size_t read, written;
int err = 0, i, ebnum, ok = 1;
loff_t addr0;
@@ -393,29 +338,27 @@ static int erasetest(void)
}
pr_info("erasing block %d\n", ebnum);
- err = erase_eraseblock(ebnum);
+ err = mtdtest_erase_eraseblock(mtd, ebnum);
if (err)
return err;
pr_info("writing 1st page of block %d\n", ebnum);
prandom_bytes_state(&rnd_state, writebuf, pgsize);
- err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
- if (err || written != pgsize) {
+ err = mtdtest_write(mtd, addr0, pgsize, writebuf);
+ if (err) {
pr_err("error: write failed at %#llx\n",
(long long)addr0);
- return err ? err : -1;
+ return err;
}
pr_info("erasing block %d\n", ebnum);
- err = erase_eraseblock(ebnum);
+ err = mtdtest_erase_eraseblock(mtd, ebnum);
if (err)
return err;
pr_info("reading 1st page of block %d\n", ebnum);
- err = mtd_read(mtd, addr0, pgsize, &read, twopages);
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr0, pgsize, twopages);
+ if (err) {
pr_err("error: read failed at %#llx\n",
(long long)addr0);
return err ? err : -1;
@@ -438,36 +381,6 @@ static int erasetest(void)
return err;
}
-static int is_block_bad(int ebnum)
-{
- loff_t addr = ebnum * mtd->erasesize;
- int ret;
-
- ret = mtd_block_isbad(mtd, addr);
- if (ret)
- pr_info("block %d is bad\n", ebnum);
- return ret;
-}
-
-static int scan_for_bad_eraseblocks(void)
-{
- int i, bad = 0;
-
- bbt = kzalloc(ebcnt, GFP_KERNEL);
- if (!bbt)
- return -ENOMEM;
-
- pr_info("scanning for bad eraseblocks\n");
- for (i = 0; i < ebcnt; ++i) {
- bbt[i] = is_block_bad(i) ? 1 : 0;
- if (bbt[i])
- bad += 1;
- cond_resched();
- }
- pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
- return 0;
-}
-
static int __init mtd_pagetest_init(void)
{
int err = 0;
@@ -521,21 +434,19 @@ static int __init mtd_pagetest_init(void)
if (!boundary)
goto out;
- err = scan_for_bad_eraseblocks();
+ bbt = kzalloc(ebcnt, GFP_KERNEL);
+ if (!bbt)
+ goto out;
+ err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, ebcnt);
if (err)
goto out;
/* Erase all eraseblocks */
pr_info("erasing whole device\n");
- for (i = 0; i < ebcnt; ++i) {
- if (bbt[i])
- continue;
- err = erase_eraseblock(i);
- if (err)
- goto out;
- cond_resched();
- }
- pr_info("erased %u eraseblocks\n", i);
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
+ if (err)
+ goto out;
+ pr_info("erased %u eraseblocks\n", ebcnt);
/* Write all eraseblocks */
prandom_seed_state(&rnd_state, 1);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 4/7] mtd: mtd_readtest: use mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
` (2 preceding siblings ...)
2013-07-27 2:14 ` [PATCH -next 3/7] mtd: mtd_pagetest: " Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 5/7] mtd: mtd_speedtest: " Akinobu Mita
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
Use mtdtest_read() and mtdtest_scan_for_bad_eraseblocks() in mtd_test
module.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/mtd_readtest.c | 51 +++++++---------------------------------
1 file changed, 9 insertions(+), 42 deletions(-)
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index 2cdd0c4..bb30773 100644
--- a/drivers/mtd/tests/mtd_readtest.c
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -29,6 +29,8 @@
#include <linux/slab.h>
#include <linux/sched.h>
+#include "mtd_test.h"
+
static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -44,24 +46,19 @@ static int pgcnt;
static int read_eraseblock_by_page(int ebnum)
{
- size_t read;
int i, ret, err = 0;
loff_t addr = ebnum * mtd->erasesize;
void *buf = iobuf;
void *oobbuf = iobuf1;
for (i = 0; i < pgcnt; i++) {
- memset(buf, 0 , pgsize);
- ret = mtd_read(mtd, addr, pgsize, &read, buf);
- if (ret == -EUCLEAN)
- ret = 0;
- if (ret || read != pgsize) {
+ memset(buf, 0 , pgcnt);
+ ret = mtdtest_read(mtd, addr, pgsize, buf);
+ if (ret) {
pr_err("error: read failed at %#llx\n",
(long long)addr);
if (!err)
err = ret;
- if (!err)
- err = -EINVAL;
}
if (mtd->oobsize) {
struct mtd_oob_ops ops;
@@ -127,39 +124,6 @@ static void dump_eraseblock(int ebnum)
}
}
-static int is_block_bad(int ebnum)
-{
- loff_t addr = ebnum * mtd->erasesize;
- int ret;
-
- ret = mtd_block_isbad(mtd, addr);
- if (ret)
- pr_info("block %d is bad\n", ebnum);
- return ret;
-}
-
-static int scan_for_bad_eraseblocks(void)
-{
- int i, bad = 0;
-
- bbt = kzalloc(ebcnt, GFP_KERNEL);
- if (!bbt)
- return -ENOMEM;
-
- if (!mtd_can_have_bb(mtd))
- return 0;
-
- pr_info("scanning for bad eraseblocks\n");
- for (i = 0; i < ebcnt; ++i) {
- bbt[i] = is_block_bad(i) ? 1 : 0;
- if (bbt[i])
- bad += 1;
- cond_resched();
- }
- pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
- return 0;
-}
-
static int __init mtd_readtest_init(void)
{
uint64_t tmp;
@@ -208,7 +172,10 @@ static int __init mtd_readtest_init(void)
if (!iobuf1)
goto out;
- err = scan_for_bad_eraseblocks();
+ bbt = kzalloc(ebcnt, GFP_KERNEL);
+ if (!bbt)
+ goto out;
+ err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, ebcnt);
if (err)
goto out;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 5/7] mtd: mtd_speedtest: use mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
` (3 preceding siblings ...)
2013-07-27 2:14 ` [PATCH -next 4/7] mtd: mtd_readtest: " Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 6/7] mtd: mtd_stresstest: " Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 7/7] mtd: mtd_subpagetest: " Akinobu Mita
6 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
Use mtdtest_write(), mtdtest_read(), mtdtest_scan_for_bad_eraseblocks(),
mtdtest_erase_whole_device() in mtd_test module.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/mtd_speedtest.c | 180 ++++++++------------------------------
1 file changed, 36 insertions(+), 144 deletions(-)
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 20b63d1..77ed5ba 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -30,6 +30,8 @@
#include <linux/sched.h>
#include <linux/random.h>
+#include "mtd_test.h"
+
static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -49,33 +51,6 @@ static int pgcnt;
static int goodebcnt;
static struct timeval start, finish;
-
-static int erase_eraseblock(int ebnum)
-{
- int err;
- struct erase_info ei;
- loff_t addr = ebnum * mtd->erasesize;
-
- memset(&ei, 0, sizeof(struct erase_info));
- ei.mtd = mtd;
- ei.addr = addr;
- ei.len = mtd->erasesize;
-
- err = mtd_erase(mtd, &ei);
- if (err) {
- pr_err("error %d while erasing EB %d\n", err, ebnum);
- return err;
- }
-
- if (ei.state == MTD_ERASE_FAILED) {
- pr_err("some erase error occurred at EB %d\n",
- ebnum);
- return -EIO;
- }
-
- return 0;
-}
-
static int multiblock_erase(int ebnum, int blocks)
{
int err;
@@ -103,52 +78,29 @@ static int multiblock_erase(int ebnum, int blocks)
return 0;
}
-static int erase_whole_device(void)
-{
- int err;
- unsigned int i;
-
- for (i = 0; i < ebcnt; ++i) {
- if (bbt[i])
- continue;
- err = erase_eraseblock(i);
- if (err)
- return err;
- cond_resched();
- }
- return 0;
-}
-
static int write_eraseblock(int ebnum)
{
- size_t written;
- int err = 0;
+ int err;
loff_t addr = ebnum * mtd->erasesize;
- err = mtd_write(mtd, addr, mtd->erasesize, &written, iobuf);
- if (err || written != mtd->erasesize) {
+ err = mtdtest_write(mtd, addr, mtd->erasesize, iobuf);
+ if (err)
pr_err("error: write failed at %#llx\n", addr);
- if (!err)
- err = -EINVAL;
- }
return err;
}
static int write_eraseblock_by_page(int ebnum)
{
- size_t written;
int i, err = 0;
loff_t addr = ebnum * mtd->erasesize;
void *buf = iobuf;
for (i = 0; i < pgcnt; i++) {
- err = mtd_write(mtd, addr, pgsize, &written, buf);
- if (err || written != pgsize) {
+ err = mtdtest_write(mtd, addr, pgsize, buf);
+ if (err) {
pr_err("error: write failed at %#llx\n",
addr);
- if (!err)
- err = -EINVAL;
break;
}
addr += pgsize;
@@ -160,30 +112,26 @@ static int write_eraseblock_by_page(int ebnum)
static int write_eraseblock_by_2pages(int ebnum)
{
- size_t written, sz = pgsize * 2;
+ size_t sz = pgsize * 2;
int i, n = pgcnt / 2, err = 0;
loff_t addr = ebnum * mtd->erasesize;
void *buf = iobuf;
for (i = 0; i < n; i++) {
- err = mtd_write(mtd, addr, sz, &written, buf);
- if (err || written != sz) {
+ err = mtdtest_write(mtd, addr, sz, buf);
+ if (err) {
pr_err("error: write failed at %#llx\n",
addr);
- if (!err)
- err = -EINVAL;
return err;
}
addr += sz;
buf += sz;
}
if (pgcnt % 2) {
- err = mtd_write(mtd, addr, pgsize, &written, buf);
- if (err || written != pgsize) {
+ err = mtdtest_write(mtd, addr, pgsize, buf);
+ if (err) {
pr_err("error: write failed at %#llx\n",
addr);
- if (!err)
- err = -EINVAL;
}
}
@@ -192,40 +140,27 @@ static int write_eraseblock_by_2pages(int ebnum)
static int read_eraseblock(int ebnum)
{
- size_t read;
- int err = 0;
+ int err;
loff_t addr = ebnum * mtd->erasesize;
- err = mtd_read(mtd, addr, mtd->erasesize, &read, iobuf);
- /* Ignore corrected ECC errors */
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != mtd->erasesize) {
+ err = mtdtest_read(mtd, addr, mtd->erasesize, iobuf);
+ if (err)
pr_err("error: read failed at %#llx\n", addr);
- if (!err)
- err = -EINVAL;
- }
return err;
}
static int read_eraseblock_by_page(int ebnum)
{
- size_t read;
int i, err = 0;
loff_t addr = ebnum * mtd->erasesize;
void *buf = iobuf;
for (i = 0; i < pgcnt; i++) {
- err = mtd_read(mtd, addr, pgsize, &read, buf);
- /* Ignore corrected ECC errors */
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, buf);
+ if (err) {
pr_err("error: read failed at %#llx\n",
addr);
- if (!err)
- err = -EINVAL;
break;
}
addr += pgsize;
@@ -237,53 +172,32 @@ static int read_eraseblock_by_page(int ebnum)
static int read_eraseblock_by_2pages(int ebnum)
{
- size_t read, sz = pgsize * 2;
+ size_t sz = pgsize * 2;
int i, n = pgcnt / 2, err = 0;
loff_t addr = ebnum * mtd->erasesize;
void *buf = iobuf;
for (i = 0; i < n; i++) {
- err = mtd_read(mtd, addr, sz, &read, buf);
- /* Ignore corrected ECC errors */
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != sz) {
+ err = mtdtest_read(mtd, addr, sz, buf);
+ if (err) {
pr_err("error: read failed at %#llx\n",
addr);
- if (!err)
- err = -EINVAL;
return err;
}
addr += sz;
buf += sz;
}
if (pgcnt % 2) {
- err = mtd_read(mtd, addr, pgsize, &read, buf);
- /* Ignore corrected ECC errors */
- if (mtd_is_bitflip(err))
- err = 0;
- if (err || read != pgsize) {
+ err = mtdtest_read(mtd, addr, pgsize, buf);
+ if (err) {
pr_err("error: read failed at %#llx\n",
addr);
- if (!err)
- err = -EINVAL;
}
}
return err;
}
-static int is_block_bad(int ebnum)
-{
- loff_t addr = ebnum * mtd->erasesize;
- int ret;
-
- ret = mtd_block_isbad(mtd, addr);
- if (ret)
- pr_info("block %d is bad\n", ebnum);
- return ret;
-}
-
static inline void start_timing(void)
{
do_gettimeofday(&start);
@@ -308,30 +222,6 @@ static long calc_speed(void)
return k;
}
-static int scan_for_bad_eraseblocks(void)
-{
- int i, bad = 0;
-
- bbt = kzalloc(ebcnt, GFP_KERNEL);
- if (!bbt)
- return -ENOMEM;
-
- if (!mtd_can_have_bb(mtd))
- goto out;
-
- pr_info("scanning for bad eraseblocks\n");
- for (i = 0; i < ebcnt; ++i) {
- bbt[i] = is_block_bad(i) ? 1 : 0;
- if (bbt[i])
- bad += 1;
- cond_resched();
- }
- pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
-out:
- goodebcnt = ebcnt - bad;
- return 0;
-}
-
static int __init mtd_speedtest_init(void)
{
int err, i, blocks, j, k;
@@ -387,11 +277,18 @@ static int __init mtd_speedtest_init(void)
prandom_bytes(iobuf, mtd->erasesize);
- err = scan_for_bad_eraseblocks();
+ bbt = kzalloc(ebcnt, GFP_KERNEL);
+ if (!bbt)
+ goto out;
+ err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, ebcnt);
if (err)
goto out;
+ for (i = 0; i < ebcnt; i++) {
+ if (!bbt[i])
+ goodebcnt++;
+ }
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -425,7 +322,7 @@ static int __init mtd_speedtest_init(void)
speed = calc_speed();
pr_info("eraseblock read speed is %ld KiB/s\n", speed);
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -459,7 +356,7 @@ static int __init mtd_speedtest_init(void)
speed = calc_speed();
pr_info("page read speed is %ld KiB/s\n", speed);
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -496,14 +393,9 @@ static int __init mtd_speedtest_init(void)
/* Erase all eraseblocks */
pr_info("Testing erase speed\n");
start_timing();
- for (i = 0; i < ebcnt; ++i) {
- if (bbt[i])
- continue;
- err = erase_eraseblock(i);
- if (err)
- goto out;
- cond_resched();
- }
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
+ if (err)
+ goto out;
stop_timing();
speed = calc_speed();
pr_info("erase speed is %ld KiB/s\n", speed);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 6/7] mtd: mtd_stresstest: use mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
` (4 preceding siblings ...)
2013-07-27 2:14 ` [PATCH -next 5/7] mtd: mtd_speedtest: " Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 7/7] mtd: mtd_subpagetest: " Akinobu Mita
6 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
Use mtdtest_read(), mtdtest_write(), mtdtest_erase_eraseblock(), and
mtdtest_scan_for_bad_eraseblocks() in mtd_test module.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/mtd_stresstest.c | 86 ++++++--------------------------------
1 file changed, 12 insertions(+), 74 deletions(-)
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 3a95e61..1e075bf 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -31,6 +31,8 @@
#include <linux/vmalloc.h>
#include <linux/random.h>
+#include "mtd_test.h"
+
static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -81,46 +83,8 @@ static int rand_len(int offs)
return len;
}
-static int erase_eraseblock(int ebnum)
-{
- int err;
- struct erase_info ei;
- loff_t addr = ebnum * mtd->erasesize;
-
- memset(&ei, 0, sizeof(struct erase_info));
- ei.mtd = mtd;
- ei.addr = addr;
- ei.len = mtd->erasesize;
-
- err = mtd_erase(mtd, &ei);
- if (unlikely(err)) {
- pr_err("error %d while erasing EB %d\n", err, ebnum);
- return err;
- }
-
- if (unlikely(ei.state == MTD_ERASE_FAILED)) {
- pr_err("some erase error occurred at EB %d\n",
- ebnum);
- return -EIO;
- }
-
- return 0;
-}
-
-static int is_block_bad(int ebnum)
-{
- loff_t addr = ebnum * mtd->erasesize;
- int ret;
-
- ret = mtd_block_isbad(mtd, addr);
- if (ret)
- pr_info("block %d is bad\n", ebnum);
- return ret;
-}
-
static int do_read(void)
{
- size_t read;
int eb = rand_eb();
int offs = rand_offs();
int len = rand_len(offs), err;
@@ -133,14 +97,10 @@ static int do_read(void)
len = mtd->erasesize - offs;
}
addr = eb * mtd->erasesize + offs;
- err = mtd_read(mtd, addr, len, &read, readbuf);
- if (mtd_is_bitflip(err))
- err = 0;
- if (unlikely(err || read != len)) {
+ err = mtdtest_read(mtd, addr, len, readbuf);
+ if (unlikely(err)) {
pr_err("error: read failed at 0x%llx\n",
(long long)addr);
- if (!err)
- err = -EINVAL;
return err;
}
return 0;
@@ -149,12 +109,11 @@ static int do_read(void)
static int do_write(void)
{
int eb = rand_eb(), offs, err, len;
- size_t written;
loff_t addr;
offs = offsets[eb];
if (offs >= mtd->erasesize) {
- err = erase_eraseblock(eb);
+ err = mtdtest_erase_eraseblock(mtd, eb);
if (err)
return err;
offs = offsets[eb] = 0;
@@ -165,19 +124,17 @@ static int do_write(void)
if (bbt[eb + 1])
len = mtd->erasesize - offs;
else {
- err = erase_eraseblock(eb + 1);
+ err = mtdtest_erase_eraseblock(mtd, eb + 1);
if (err)
return err;
offsets[eb + 1] = 0;
}
}
addr = eb * mtd->erasesize + offs;
- err = mtd_write(mtd, addr, len, &written, writebuf);
- if (unlikely(err || written != len)) {
+ err = mtdtest_write(mtd, addr, len, writebuf);
+ if (unlikely(err)) {
pr_err("error: write failed at 0x%llx\n",
(long long)addr);
- if (!err)
- err = -EINVAL;
return err;
}
offs += len;
@@ -197,28 +154,6 @@ static int do_operation(void)
return do_write();
}
-static int scan_for_bad_eraseblocks(void)
-{
- int i, bad = 0;
-
- bbt = kzalloc(ebcnt, GFP_KERNEL);
- if (!bbt)
- return -ENOMEM;
-
- if (!mtd_can_have_bb(mtd))
- return 0;
-
- pr_info("scanning for bad eraseblocks\n");
- for (i = 0; i < ebcnt; ++i) {
- bbt[i] = is_block_bad(i) ? 1 : 0;
- if (bbt[i])
- bad += 1;
- cond_resched();
- }
- pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
- return 0;
-}
-
static int __init mtd_stresstest_init(void)
{
int err;
@@ -280,7 +215,10 @@ static int __init mtd_stresstest_init(void)
offsets[i] = mtd->erasesize;
prandom_bytes(writebuf, bufsize);
- err = scan_for_bad_eraseblocks();
+ bbt = kzalloc(ebcnt, GFP_KERNEL);
+ if (!bbt)
+ goto out;
+ err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, ebcnt);
if (err)
goto out;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH -next 7/7] mtd: mtd_subpagetest: use mtd_test module
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
` (5 preceding siblings ...)
2013-07-27 2:14 ` [PATCH -next 6/7] mtd: mtd_stresstest: " Akinobu Mita
@ 2013-07-27 2:14 ` Akinobu Mita
6 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-27 2:14 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita, Adrian Hunter
Use mtdtest_scan_for_bad_eraseblocks() and mtdtest_erase_whole_device()
in mtd_test module.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/mtd_subpagetest.c | 87 ++++---------------------------------
1 file changed, 9 insertions(+), 78 deletions(-)
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index e41a04f..0db1247 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -30,6 +30,8 @@
#include <linux/sched.h>
#include <linux/random.h>
+#include "mtd_test.h"
+
static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -51,50 +53,6 @@ static inline void clear_data(unsigned char *buf, size_t len)
memset(buf, 0, len);
}
-static int erase_eraseblock(int ebnum)
-{
- int err;
- struct erase_info ei;
- loff_t addr = ebnum * mtd->erasesize;
-
- memset(&ei, 0, sizeof(struct erase_info));
- ei.mtd = mtd;
- ei.addr = addr;
- ei.len = mtd->erasesize;
-
- err = mtd_erase(mtd, &ei);
- if (err) {
- pr_err("error %d while erasing EB %d\n", err, ebnum);
- return err;
- }
-
- if (ei.state == MTD_ERASE_FAILED) {
- pr_err("some erase error occurred at EB %d\n",
- ebnum);
- return -EIO;
- }
-
- return 0;
-}
-
-static int erase_whole_device(void)
-{
- int err;
- unsigned int i;
-
- pr_info("erasing whole device\n");
- for (i = 0; i < ebcnt; ++i) {
- if (bbt[i])
- continue;
- err = erase_eraseblock(i);
- if (err)
- return err;
- cond_resched();
- }
- pr_info("erased %u eraseblocks\n", i);
- return 0;
-}
-
static int write_eraseblock(int ebnum)
{
size_t written;
@@ -317,36 +275,6 @@ static int verify_all_eraseblocks_ff(void)
return 0;
}
-static int is_block_bad(int ebnum)
-{
- loff_t addr = ebnum * mtd->erasesize;
- int ret;
-
- ret = mtd_block_isbad(mtd, addr);
- if (ret)
- pr_info("block %d is bad\n", ebnum);
- return ret;
-}
-
-static int scan_for_bad_eraseblocks(void)
-{
- int i, bad = 0;
-
- bbt = kzalloc(ebcnt, GFP_KERNEL);
- if (!bbt)
- return -ENOMEM;
-
- pr_info("scanning for bad eraseblocks\n");
- for (i = 0; i < ebcnt; ++i) {
- bbt[i] = is_block_bad(i) ? 1 : 0;
- if (bbt[i])
- bad += 1;
- cond_resched();
- }
- pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
- return 0;
-}
-
static int __init mtd_subpagetest_init(void)
{
int err = 0;
@@ -396,12 +324,15 @@ static int __init mtd_subpagetest_init(void)
readbuf = kmalloc(bufsize, GFP_KERNEL);
if (!readbuf)
goto out;
+ bbt = kzalloc(ebcnt, GFP_KERNEL);
+ if (!bbt)
+ goto out;
- err = scan_for_bad_eraseblocks();
+ err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, ebcnt);
if (err)
goto out;
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -433,7 +364,7 @@ static int __init mtd_subpagetest_init(void)
}
pr_info("verified %u eraseblocks\n", i);
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
@@ -471,7 +402,7 @@ static int __init mtd_subpagetest_init(void)
}
pr_info("verified %u eraseblocks\n", i);
- err = erase_whole_device();
+ err = mtdtest_erase_whole_device(mtd, bbt, ebcnt);
if (err)
goto out;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-27 2:14 ` [PATCH -next 1/7] mtd: tests: introduce mtd_test module Akinobu Mita
@ 2013-07-27 19:27 ` Brian Norris
2013-07-28 2:21 ` Akinobu Mita
2013-08-02 14:05 ` Artem Bityutskiy
0 siblings, 2 replies; 15+ messages in thread
From: Brian Norris @ 2013-07-27 19:27 UTC (permalink / raw)
To: Akinobu Mita; +Cc: David Woodhouse, linux-mtd, Adrian Hunter, Artem Bityutskiy
On Fri, Jul 26, 2013 at 7:14 PM, Akinobu Mita <akinobu.mita@gmail.com> wrote:
> This introduces mtd_test module which contains the following functions
> used by several mtd/tests modules.
>
> - mtdtest_erase_eraseblock()
> - mtdtest_scan_for_bad_eraseblocks()
> - mtdtest_erase_whole_device()
>
> This mtd_test module also provides the following wrapper functions for
> mtd_read() and mtd_write() in order to simplify the return value check
> in mtd/tests modules.
>
> - mtdtest_read()
> - mtdtest_write()
>
> These functions will be used for reducing code duplication among
> mtd/tests modules later.
I like this idea. There is definitely too much code duplication.
However, there is an important tradeoff here: now to run these (very
simple) tests, we have a two-step process*:
insmod mtd_test.ko
insmod mtd_<actualtest>.ko dev=<MTD>
[* modprobe would solve this problem, but these tests are often
compiled and run by hand, sometimes on systems without the convenience
of modprobe ]
We could still accomplish the reduction in (source) code duplication
by simply including these simple routines in a header, then the code
would be compiled into each test module. I realize this isn't
typically the "best" way to share code, but since these are just test
modules and really don't need to be optimized for code size, I think
it is worth avoiding the extra step of inserting another module.
> ---
> drivers/mtd/tests/Makefile | 1 +
> drivers/mtd/tests/mtd_test.c | 117 +++++++++++++++++++++++++++++++++++++++++++
> drivers/mtd/tests/mtd_test.h | 11 ++++
> 3 files changed, 129 insertions(+)
> create mode 100644 drivers/mtd/tests/mtd_test.c
> create mode 100644 drivers/mtd/tests/mtd_test.h
If we still keep the mtd_test module separate, I might rename it to
help distinguish it from any of the other modules, which actually run
tests. Perhaps include "lib" in the name? Like "libmtdtest.{c,h}"?
> diff --git a/drivers/mtd/tests/mtd_test.c b/drivers/mtd/tests/mtd_test.c
> new file mode 100644
> index 0000000..1fa1d63
> --- /dev/null
> +++ b/drivers/mtd/tests/mtd_test.c
> @@ -0,0 +1,117 @@
...
> +MODULE_LICENSE("GPL");
If we're keeping this as a module, we might want at least a
MODULE_DESCRIPTION (to help a user understand why they need this extra
module) and possibly a MODULE_AUTHOR?
Brian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-27 19:27 ` Brian Norris
@ 2013-07-28 2:21 ` Akinobu Mita
2013-07-28 4:39 ` Vikram Narayanan
2013-08-02 14:05 ` Artem Bityutskiy
1 sibling, 1 reply; 15+ messages in thread
From: Akinobu Mita @ 2013-07-28 2:21 UTC (permalink / raw)
To: Brian Norris; +Cc: David Woodhouse, linux-mtd, Adrian Hunter, Artem Bityutskiy
2013/7/28 Brian Norris <computersforpeace@gmail.com>:
> I like this idea. There is definitely too much code duplication.
>
> However, there is an important tradeoff here: now to run these (very
> simple) tests, we have a two-step process*:
>
> insmod mtd_test.ko
> insmod mtd_<actualtest>.ko dev=<MTD>
>
> [* modprobe would solve this problem, but these tests are often
> compiled and run by hand, sometimes on systems without the convenience
> of modprobe ]
>
> We could still accomplish the reduction in (source) code duplication
> by simply including these simple routines in a header, then the code
> would be compiled into each test module. I realize this isn't
> typically the "best" way to share code, but since these are just test
> modules and really don't need to be optimized for code size, I think
> it is worth avoiding the extra step of inserting another module.
I understand your concern and I'm going to change this series to move
all these functions into a header file. But I'll wait other opinion
for a while.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-28 2:21 ` Akinobu Mita
@ 2013-07-28 4:39 ` Vikram Narayanan
2013-07-28 4:41 ` Vikram Narayanan
0 siblings, 1 reply; 15+ messages in thread
From: Vikram Narayanan @ 2013-07-28 4:39 UTC (permalink / raw)
To: Akinobu Mita
Cc: linux-mtd, Brian Norris, David Woodhouse, Adrian Hunter,
Artem Bityutskiy
On 28/Jul/2013 7:51 AM, Akinobu Mita wrote:
> 2013/7/28 Brian Norris <computersforpeace@gmail.com>:
>> I like this idea. There is definitely too much code duplication.
>>
>> However, there is an important tradeoff here: now to run these (very
>> simple) tests, we have a two-step process*:
>>
>> insmod mtd_test.ko
>> insmod mtd_<actualtest>.ko dev=<MTD>
>>
>> [* modprobe would solve this problem, but these tests are often
>> compiled and run by hand, sometimes on systems without the convenience
>> of modprobe ]
>>
>> We could still accomplish the reduction in (source) code duplication
>> by simply including these simple routines in a header, then the code
>> would be compiled into each test module. I realize this isn't
>> typically the "best" way to share code, but since these are just test
>> modules and really don't need to be optimized for code size, I think
>> it is worth avoiding the extra step of inserting another module.
>
> I understand your concern and I'm going to change this series to move
> all these functions into a header file. But I'll wait other opinion
> for a while.
You can refer this.
<http://thread.gmane.org/gmane.linux.drivers.mtd/43932/focus=43941>
And also Artem's feedback here
<http://thread.gmane.org/gmane.linux.drivers.mtd/43932/focus=43941>
However, I didn't get much time to make this patch better as Artem
suggested.
~Vikram
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-28 4:39 ` Vikram Narayanan
@ 2013-07-28 4:41 ` Vikram Narayanan
2013-07-29 3:15 ` Akinobu Mita
0 siblings, 1 reply; 15+ messages in thread
From: Vikram Narayanan @ 2013-07-28 4:41 UTC (permalink / raw)
To: Akinobu Mita
Cc: linux-mtd, Brian Norris, David Woodhouse, Adrian Hunter,
Artem Bityutskiy
On 28/Jul/2013 10:09 AM, Vikram Narayanan wrote:
> On 28/Jul/2013 7:51 AM, Akinobu Mita wrote:
>> 2013/7/28 Brian Norris <computersforpeace@gmail.com>:
>>> I like this idea. There is definitely too much code duplication.
>>>
>>> However, there is an important tradeoff here: now to run these (very
>>> simple) tests, we have a two-step process*:
>>>
>>> insmod mtd_test.ko
>>> insmod mtd_<actualtest>.ko dev=<MTD>
>>>
>>> [* modprobe would solve this problem, but these tests are often
>>> compiled and run by hand, sometimes on systems without the convenience
>>> of modprobe ]
>>>
>>> We could still accomplish the reduction in (source) code duplication
>>> by simply including these simple routines in a header, then the code
>>> would be compiled into each test module. I realize this isn't
>>> typically the "best" way to share code, but since these are just test
>>> modules and really don't need to be optimized for code size, I think
>>> it is worth avoiding the extra step of inserting another module.
>>
>> I understand your concern and I'm going to change this series to move
>> all these functions into a header file. But I'll wait other opinion
>> for a while.
>
> You can refer this.
> <http://thread.gmane.org/gmane.linux.drivers.mtd/43932/focus=43941>
http://article.gmane.org/gmane.linux.drivers.mtd/43933
> And also Artem's feedback here
> <http://thread.gmane.org/gmane.linux.drivers.mtd/43932/focus=43941>
http://article.gmane.org/gmane.linux.drivers.mtd/44007
>
> However, I didn't get much time to make this patch better as Artem
> suggested.
>
> ~Vikram
Sorry, Now updated the thread with correct links.
~Vikram
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-28 4:41 ` Vikram Narayanan
@ 2013-07-29 3:15 ` Akinobu Mita
0 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-07-29 3:15 UTC (permalink / raw)
To: Vikram Narayanan
Cc: linux-mtd, Brian Norris, David Woodhouse, Adrian Hunter,
Artem Bityutskiy
2013/7/28 Vikram Narayanan <vikram186@gmail.com>:
> On 28/Jul/2013 10:09 AM, Vikram Narayanan wrote:
>>
>> On 28/Jul/2013 7:51 AM, Akinobu Mita wrote:
>>>
>>> 2013/7/28 Brian Norris <computersforpeace@gmail.com>:
>>>>
>>>> I like this idea. There is definitely too much code duplication.
>>>>
>>>> However, there is an important tradeoff here: now to run these (very
>>>> simple) tests, we have a two-step process*:
>>>>
>>>> insmod mtd_test.ko
>>>> insmod mtd_<actualtest>.ko dev=<MTD>
>>>>
>>>> [* modprobe would solve this problem, but these tests are often
>>>> compiled and run by hand, sometimes on systems without the convenience
>>>> of modprobe ]
>>>>
>>>> We could still accomplish the reduction in (source) code duplication
>>>> by simply including these simple routines in a header, then the code
>>>> would be compiled into each test module. I realize this isn't
>>>> typically the "best" way to share code, but since these are just test
>>>> modules and really don't need to be optimized for code size, I think
>>>> it is worth avoiding the extra step of inserting another module.
>>>
>>>
>>> I understand your concern and I'm going to change this series to move
>>> all these functions into a header file. But I'll wait other opinion
>>> for a while.
>>
>>
>> You can refer this.
>> <http://thread.gmane.org/gmane.linux.drivers.mtd/43932/focus=43941>
>
>
> http://article.gmane.org/gmane.linux.drivers.mtd/43933
Thanks. I noticed that there were a few more places where erase_eraseblock()
could be used in mtd/tests modules. I'll include these in next version
of this patch set.
>> And also Artem's feedback here
>> <http://thread.gmane.org/gmane.linux.drivers.mtd/43932/focus=43941>
>
>
> http://article.gmane.org/gmane.linux.drivers.mtd/44007
I checked all callsites of mtd_erase() in the tree, but there is no places where
we can simply use erase_eraseblock(). If erase_eraseblock() can take
additional arguments (callback and priv), there are only a few places
(in mtdswap.c and ubi/io.c) where we can use it. So I think we don't
need to extend mtdcore.c for now.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-07-27 19:27 ` Brian Norris
2013-07-28 2:21 ` Akinobu Mita
@ 2013-08-02 14:05 ` Artem Bityutskiy
2013-08-03 7:55 ` Akinobu Mita
1 sibling, 1 reply; 15+ messages in thread
From: Artem Bityutskiy @ 2013-08-02 14:05 UTC (permalink / raw)
To: Brian Norris, Akinobu Mita; +Cc: David Woodhouse, linux-mtd, Adrian Hunter
On Sat, 2013-07-27 at 12:27 -0700, Brian Norris wrote:
> > These functions will be used for reducing code duplication among
> > mtd/tests modules later.
>
> I like this idea. There is definitely too much code duplication.
>
> However, there is an important tradeoff here: now to run these (very
> simple) tests, we have a two-step process*:
>
> insmod mtd_test.ko
> insmod mtd_<actualtest>.ko dev=<MTD>
The helpers do not have to be in a separate module. Here is a short
patch demonstrating how we could put all the helpers to a single .c file
and then just link it to the tests.
It renames mtd_oobtest.c to oobtest.c, and this part of the patch is
omitted. Do it by hand if you want to try this patch:
$ mv drivers/mtd/tests/mtd_oobtest.c drivers/mtd/tests/oobtest.c
Note, I do realize that the code will actually be copied to every test
module, but I think it is fine for our small test infrastructure.
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date: Fri, 2 Aug 2013 16:41:37 +0300
Subject: [PATCH] tmp: a patch to demonstrate a possible way of having test
helpers
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
drivers/mtd/tests/Makefile | 2 +
drivers/mtd/tests/mtd_oobtest.c | 714 --------------------------------------
drivers/mtd/tests/oobtest.c | 718 +++++++++++++++++++++++++++++++++++++++
drivers/mtd/tests/test_helpers.c | 6 +
drivers/mtd/tests/test_helpers.h | 1 +
5 files changed, 727 insertions(+), 714 deletions(-)
delete mode 100644 drivers/mtd/tests/mtd_oobtest.c
create mode 100644 drivers/mtd/tests/oobtest.c
create mode 100644 drivers/mtd/tests/test_helpers.c
create mode 100644 drivers/mtd/tests/test_helpers.h
diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile
index bd0065c..41a34d3 100644
--- a/drivers/mtd/tests/Makefile
+++ b/drivers/mtd/tests/Makefile
@@ -7,3 +7,5 @@ obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o
obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o
obj-$(CONFIG_MTD_TESTS) += mtd_nandecctest.o
obj-$(CONFIG_MTD_TESTS) += mtd_nandbiterrs.o
+
+mtd_oobtest-objs := oobtest.o test_helpers.o
diff --git a/drivers/mtd/tests/test_helpers.c b/drivers/mtd/tests/test_helpers.c
new file mode 100644
index 0000000..70c4692
--- /dev/null
+++ b/drivers/mtd/tests/test_helpers.c
@@ -0,0 +1,6 @@
+#include "test_helpers.h"
+
+int a_helper(void)
+{
+ return 0;
+}
diff --git a/drivers/mtd/tests/test_helpers.h b/drivers/mtd/tests/test_helpers.h
new file mode 100644
index 0000000..0948a6e
--- /dev/null
+++ b/drivers/mtd/tests/test_helpers.h
@@ -0,0 +1 @@
+int a_helper(void);
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH -next 1/7] mtd: tests: introduce mtd_test module
2013-08-02 14:05 ` Artem Bityutskiy
@ 2013-08-03 7:55 ` Akinobu Mita
0 siblings, 0 replies; 15+ messages in thread
From: Akinobu Mita @ 2013-08-03 7:55 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: David Woodhouse, Brian Norris, linux-mtd, Adrian Hunter
2013/8/2 Artem Bityutskiy <dedekind1@gmail.com>:
> On Sat, 2013-07-27 at 12:27 -0700, Brian Norris wrote:
>> > These functions will be used for reducing code duplication among
>> > mtd/tests modules later.
>>
>> I like this idea. There is definitely too much code duplication.
>>
>> However, there is an important tradeoff here: now to run these (very
>> simple) tests, we have a two-step process*:
>>
>> insmod mtd_test.ko
>> insmod mtd_<actualtest>.ko dev=<MTD>
>
> The helpers do not have to be in a separate module. Here is a short
> patch demonstrating how we could put all the helpers to a single .c file
> and then just link it to the tests.
>
> It renames mtd_oobtest.c to oobtest.c, and this part of the patch is
> omitted. Do it by hand if you want to try this patch:
>
> $ mv drivers/mtd/tests/mtd_oobtest.c drivers/mtd/tests/oobtest.c
>
> Note, I do realize that the code will actually be copied to every test
> module, but I think it is fine for our small test infrastructure.
I took this idea. I have finished rewriting this patch series and
testing with nandsim using badblocks module parameter. I'll send
next version later on.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-08-03 7:56 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-27 2:14 [PATCH -next 0/7] mtd: tests: reduce duplication among mtd tests modules Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 1/7] mtd: tests: introduce mtd_test module Akinobu Mita
2013-07-27 19:27 ` Brian Norris
2013-07-28 2:21 ` Akinobu Mita
2013-07-28 4:39 ` Vikram Narayanan
2013-07-28 4:41 ` Vikram Narayanan
2013-07-29 3:15 ` Akinobu Mita
2013-08-02 14:05 ` Artem Bityutskiy
2013-08-03 7:55 ` Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 2/7] mtd: mtd_oobtest: use " Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 3/7] mtd: mtd_pagetest: " Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 4/7] mtd: mtd_readtest: " Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 5/7] mtd: mtd_speedtest: " Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 6/7] mtd: mtd_stresstest: " Akinobu Mita
2013-07-27 2:14 ` [PATCH -next 7/7] mtd: mtd_subpagetest: " Akinobu Mita
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.