From patchwork Fri Jan 27 14:24:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 138233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 78503B6EEC for ; Sat, 28 Jan 2012 01:26:15 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Rqmk2-0007V7-Pr; Fri, 27 Jan 2012 14:25:27 +0000 Received: from mail-pw0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Rqmji-0007KX-Jr for linux-mtd@lists.infradead.org; Fri, 27 Jan 2012 14:25:07 +0000 Received: by mail-pw0-f49.google.com with SMTP id x9so2050943pbd.36 for ; Fri, 27 Jan 2012 06:25:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=zXPAupY5cJGbskv2Z5i2hf+hMuRy0STFW73A3L0OcQw=; b=Dum/h+r/adfIAtOTGFx7Ps+RmEppQzTYpQc2P5h+62b6DiUX1VBTfK9KFUu68yqYtg BoxBx7mPOs1I+ZyAv2csHSuHjlGDE7BNWK4nU0ybnxBFxU/lqdJz31qkLdqzUb8TgGyo TFaiL5ebvZwTAmp5+AeLRjVKAmBqZCQ+ruhQY= Received: by 10.68.199.163 with SMTP id jl3mr14619194pbc.78.1327674306118; Fri, 27 Jan 2012 06:25:06 -0800 (PST) Received: from localhost.localdomain (p2046-adsao01yokonib2-acca.kanagawa.ocn.ne.jp. [61.214.148.46]) by mx.google.com with ESMTPS id lk11sm20385743pbb.0.2012.01.27.06.25.02 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jan 2012 06:25:05 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: [PATCH] mtd/tests: use memchr_inv Date: Fri, 27 Jan 2012 23:24:54 +0900 Message-Id: <1327674295-3700-7-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1327674295-3700-1-git-send-email-akinobu.mita@gmail.com> References: <1327674295-3700-1-git-send-email-akinobu.mita@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] 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: linux-mtd@lists.infradead.org, David Woodhouse , Akinobu Mita X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 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-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use memchr_inv to check if the data contains all 0xFF bytes. It is faster than looping for each byte. Signed-off-by: Akinobu Mita Cc: David Woodhouse Cc: linux-mtd@lists.infradead.org --- drivers/mtd/tests/mtd_pagetest.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c index 252ddb0..08847cf 100644 --- a/drivers/mtd/tests/mtd_pagetest.c +++ b/drivers/mtd/tests/mtd_pagetest.c @@ -401,6 +401,7 @@ static int erasetest(void) size_t read, written; int err = 0, i, ebnum, ok = 1; loff_t addr0; + unsigned char *p; printk(PRINT_PREF "erasetest\n"); @@ -442,14 +443,13 @@ static int erasetest(void) printk(PRINT_PREF "verifying 1st page of block %d is all 0xff\n", ebnum); - for (i = 0; i < pgsize; ++i) - if (twopages[i] != 0xff) { - printk(PRINT_PREF "verifying all 0xff failed at %d\n", - i); - errcnt += 1; - ok = 0; - break; - } + p = memchr_inv(twopages, 0xff, pgsize); + if (p) { + printk(PRINT_PREF "verifying all 0xff failed at %d\n", + p - twopages); + errcnt += 1; + ok = 0; + } if (ok && !err) printk(PRINT_PREF "erasetest ok\n");