From patchwork Sat Jul 27 02:14:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 262376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7E77C2C0100 for ; Sat, 27 Jul 2013 12:21:16 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2u80-0004g7-Qq; Sat, 27 Jul 2013 02:21:05 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2u7z-0008PJ-28; Sat, 27 Jul 2013 02:21:03 +0000 Received: from mail-pb0-x22b.google.com ([2607:f8b0:400e:c01::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2u7u-0008Ow-PQ for linux-mtd@lists.infradead.org; Sat, 27 Jul 2013 02:21:01 +0000 Received: by mail-pb0-f43.google.com with SMTP id md12so2639810pbc.2 for ; Fri, 26 Jul 2013 19:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=OdFUZ1kFMgOkuq47+fMwLx1lSiD8FHLgHK/fcUWXoBw=; b=JsNg/WoLtNeXqD4SSks2jqeMhqluR+oKDWhkrXi2tkU8Ch6FQ++L/FRqxfUlWGEMfl dC90uiOCw71GGbdCvD5RAs52IJGEOvaDov2cgTazxd9hIXgyjWHT8n4nHshTyaA3XRzC OnqboFyVei4IY58XBJIudDwaoEnmpGib/+LlF1TGLc5dkimbIc0taK4s/aOuxUtfmCyr k11aaygbCn6OeAPesws53jmLo1qSQSq02AZ+iGj7FMfZMETvcshv+tz704MZiZAUmnqy G7SBpsCLfWBav1YWSrrRMLc6RN0Jy/8faGOvEEsXBvUmA0LwWuCUyyMSlwOegCXA7Q09 neVg== X-Received: by 10.68.166.5 with SMTP id zc5mr56878410pbb.16.1374891313188; Fri, 26 Jul 2013 19:15:13 -0700 (PDT) Received: from localhost.localdomain (KD113145060135.ppp-bb.dion.ne.jp. [113.145.60.135]) by mx.google.com with ESMTPSA id bg3sm62887200pbb.44.2013.07.26.19.15.11 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 26 Jul 2013 19:15:12 -0700 (PDT) From: Akinobu Mita To: linux-mtd@lists.infradead.org Subject: [PATCH -next 7/7] mtd: mtd_subpagetest: use mtd_test module Date: Sat, 27 Jul 2013 11:14:16 +0900 Message-Id: <1374891256-20248-8-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1374891256-20248-1-git-send-email-akinobu.mita@gmail.com> References: <1374891256-20248-1-git-send-email-akinobu.mita@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130726_222058_932741_FFA37003 X-CRM114-Status: GOOD ( 15.83 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (akinobu.mita[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Artem Bityutskiy , David Woodhouse , Akinobu Mita , Adrian Hunter X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use mtdtest_scan_for_bad_eraseblocks() and mtdtest_erase_whole_device() in mtd_test module. Signed-off-by: Akinobu Mita Cc: Adrian Hunter Cc: Artem Bityutskiy Cc: David Woodhouse 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 #include +#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;