[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1327674295-3700-5-git-send-email-akinobu.mita@gmail.com>
Date: Fri, 27 Jan 2012 23:24:52 +0900
From: Akinobu Mita <akinobu.mita@...il.com>
To: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Cc: Akinobu Mita <akinobu.mita@...il.com>,
David Woodhouse <dwmw2@...radead.org>,
linux-mtd@...ts.infradead.org
Subject: [PATCH] mtd/inftlmount: use memchr_inv
Use memchr_inv to check if the data contains all 0xFF bytes. It is
faster than looping for each byte.
This also removes memcmpb which is no longer used.
Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>
Cc: linux-mtd@...ts.infradead.org
---
drivers/mtd/inftlmount.c | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index 4adc037..419b1c9 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -320,16 +320,6 @@ static int find_boot_record(struct INFTLrecord *inftl)
return -1;
}
-static int memcmpb(void *a, int c, int n)
-{
- int i;
- for (i = 0; i < n; i++) {
- if (c != ((unsigned char *)a)[i])
- return 1;
- }
- return 0;
-}
-
/*
* check_free_sector: check if a free sector is actually FREE,
* i.e. All 0xff in data and oob area.
@@ -345,14 +335,14 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
for (i = 0; i < len; i += SECTORSIZE) {
if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf))
return -1;
- if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
+ if (memchr_inv(buf, 0xff, SECTORSIZE))
return -1;
if (check_oob) {
if(inftl_read_oob(mtd, address, mtd->oobsize,
&retlen, &buf[SECTORSIZE]) < 0)
return -1;
- if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
+ if (memchr_inv(buf + SECTORSIZE, 0xff, mtd->oobsize))
return -1;
}
address += SECTORSIZE;
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists