From patchwork Sat Jul 27 02:14:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 262371 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 1AABC2C0103 for ; Sat, 27 Jul 2013 12:16:10 +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 1V2u2w-0003J8-CB; Sat, 27 Jul 2013 02:15:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2u2p-0008K2-Ba; Sat, 27 Jul 2013 02:15:43 +0000 Received: from mail-pb0-x230.google.com ([2607:f8b0:400e:c01::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2u2a-0008Fe-Op for linux-mtd@lists.infradead.org; Sat, 27 Jul 2013 02:15:36 +0000 Received: by mail-pb0-f48.google.com with SMTP id md4so2638794pbc.21 for ; Fri, 26 Jul 2013 19:15:07 -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=S7oOBXXLpvTVaSDFEe7zmcCRQXH4QlgLpzchSD4T9j8=; b=v6U8f4q/CV7Ad076YBjO7lOU5vCex1OCNH1Lm5x3Gey7whtGwDYkqDi9bahDs6LkiF HL/ijzYVWnQm2VkwYFxiyK02YCh6k3qo+Nz6S6I6M/hPLmUENhNnnCMiGm/XS+9CYXIi EA4eCTc49dPRSfI25+Co8w3Pv8JXB+YMTsuZSBhHag5ChN2zu9PYHrmf81Gru6u76LSD 0Z33N+s9glGDXgYqQgHpaEESf5RXwqK7HSDrmk7XZbGTGZvZrslvf2q8pcmz3zFwdBCZ iID6VohL4VrvKaE11jLPfgmIa20awvxDIw0S9PYwU1LuGbFAq7tI5xNHUhvWSEznFNE2 3bhA== X-Received: by 10.68.34.165 with SMTP id a5mr56193641pbj.156.1374891307272; Fri, 26 Jul 2013 19:15:07 -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.05 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 26 Jul 2013 19:15:06 -0700 (PDT) From: Akinobu Mita To: linux-mtd@lists.infradead.org Subject: [PATCH -next 4/7] mtd: mtd_readtest: use mtd_test module Date: Sat, 27 Jul 2013 11:14:13 +0900 Message-Id: <1374891256-20248-5-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_221529_125800_5F1E3225 X-CRM114-Status: GOOD ( 15.07 ) 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_read() and mtdtest_scan_for_bad_eraseblocks() 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_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 #include +#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;