lkml.org 
[lkml]   [2012]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mtd/tests: use memchr_inv
Date
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 <akinobu.mita@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
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");
--
1.7.4.4


\
 
 \ /
  Last update: 2012-01-27 15:27    [from the cache]
©2003-2011 Jasper Spaans