Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332680
b: refs/heads/master
c: 491ed06
h: refs/heads/master
v: v3
  • Loading branch information
Brian Norris authored and David Woodhouse committed Sep 29, 2012
1 parent 3beef21 commit b753552
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7b5a2d40978fbb046b99b4030ce2785b66a451a5
refs/heads/master: 491ed06f334955578f0c43d298c46ea1a7ea9e1b
27 changes: 9 additions & 18 deletions trunk/drivers/mtd/nand/nand_bbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include <linux/delay.h>
#include <linux/vmalloc.h>
#include <linux/export.h>
#include <linux/string.h>

static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td)
{
Expand All @@ -89,19 +90,16 @@ static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td)
*/
static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
{
int i, end = 0;
int end = 0;
uint8_t *p = buf;

if (td->options & NAND_BBT_NO_OOB)
return check_pattern_no_oob(buf, td);

end = paglen + td->offs;
if (td->options & NAND_BBT_SCANEMPTY) {
for (i = 0; i < end; i++) {
if (p[i] != 0xff)
return -1;
}
}
if (td->options & NAND_BBT_SCANEMPTY)
if (memchr_inv(p, 0xff, end))
return -1;
p += end;

/* Compare the pattern */
Expand All @@ -111,10 +109,8 @@ static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_desc
if (td->options & NAND_BBT_SCANEMPTY) {
p += td->len;
end += td->len;
for (i = end; i < len; i++) {
if (*p++ != 0xff)
return -1;
}
if (memchr_inv(p, 0xff, len - end))
return -1;
}
return 0;
}
Expand All @@ -130,14 +126,9 @@ static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_desc
*/
static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
{
int i;
uint8_t *p = buf;

/* Compare the pattern */
for (i = 0; i < td->len; i++) {
if (p[td->offs + i] != td->pattern[i])
return -1;
}
if (memcmp(buf + td->offs, td->pattern, td->len))
return -1;
return 0;
}

Expand Down

0 comments on commit b753552

Please sign in to comment.