From patchwork Sat Aug 3 09:52:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 264408 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 3023D2C0087 for ; Sat, 3 Aug 2013 19:54:17 +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 1V5YX8-0002kV-2V; Sat, 03 Aug 2013 09:53:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5YWx-0006dU-PF; Sat, 03 Aug 2013 09:53:47 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5YWk-0006Y3-Dz for linux-mtd@lists.infradead.org; Sat, 03 Aug 2013 09:53:45 +0000 Received: by mail-pa0-f42.google.com with SMTP id lj1so1535371pab.1 for ; Sat, 03 Aug 2013 02:53:12 -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=UojVLtfP9ALkfIZH0cXRK168KPutHGYr/kPqDpEzeDA=; b=ahSXcClTtCd3R/lFoppZDXkmmeysetD3VMpn3rd/IKqAHWOSkr6t4Bn3Dnk34ykcle NED0wwg7jcRMeg+M6yIxaZKWbyBhpsNoByi9ox4diwW/hqr4iqAEf2RCnHfKCLo4KkiP UKDhrZuwp96jpsym5hWiH4ucXavPCgnk27gS0MsRb3ilXIyFPEu3gyiTie/ZKx4Z5Xih rqMbPbYi+fHXfau6IrqGSjPWSc2ZmXuZzCFNr5et1zvQp9TtbsuCSrYRIvux5qsnFS7g qURbjCNzQB4Eb7A3Ve47n1WePoWL4lnMrGkN/7l+SWkWzm7mkpn4N2cy00j/mqDFEFi7 eIVw== X-Received: by 10.67.1.101 with SMTP id bf5mr14646303pad.50.1375523592894; Sat, 03 Aug 2013 02:53:12 -0700 (PDT) Received: from localhost.localdomain (KD113145060135.ppp-bb.dion.ne.jp. [113.145.60.135]) by mx.google.com with ESMTPSA id ib9sm15295755pbc.43.2013.08.03.02.53.11 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 03 Aug 2013 02:53:12 -0700 (PDT) From: Akinobu Mita To: linux-mtd@lists.infradead.org Subject: [PATCH -next v2 05/10] mtd: mtd_readtest: use mtd_test helpers Date: Sat, 3 Aug 2013 18:52:11 +0900 Message-Id: <1375523536-32671-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1375523536-32671-1-git-send-email-akinobu.mita@gmail.com> References: <1375523536-32671-1-git-send-email-akinobu.mita@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130803_055334_610794_929A49A6 X-CRM114-Status: GOOD ( 15.87 ) 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 , Vikram Narayanan , Akinobu Mita , Adrian Hunter , Brian Norris , David Woodhouse 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 helpers. Signed-off-by: Akinobu Mita Cc: Brian Norris Cc: Vikram Narayanan Cc: Adrian Hunter Cc: Artem Bityutskiy Cc: David Woodhouse Cc: linux-mtd@lists.infradead.org --- * Changes from v1 - follow the changes of helper functions - fix accidentally changed argument of memset() in mtd_readtest module drivers/mtd/tests/readtest.c | 49 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/drivers/mtd/tests/readtest.c b/drivers/mtd/tests/readtest.c index 2cdd0c4..ffd50d6 100644 --- a/drivers/mtd/tests/readtest.c +++ b/drivers/mtd/tests/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,7 +46,6 @@ 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; @@ -52,16 +53,12 @@ static int read_eraseblock_by_page(int ebnum) 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) { + 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, 0, ebcnt); if (err) goto out;