mtd: nand: refactor scanning code
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Mon Nov 7 11:59:33 EST 2011
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=105513cc4a25522f959788371bd612f987d4d184
Commit: 105513cc4a25522f959788371bd612f987d4d184
Parent: 3e2b82b9073e8bf0b4f359fa3045e81d9fe87f7d
Author: Brian Norris <computersforpeace at gmail.com>
AuthorDate: Wed Sep 7 13:13:28 2011 -0700
Committer: Artem Bityutskiy <artem.bityutskiy at intel.com>
CommitDate: Sun Sep 11 16:48:47 2011 +0300
mtd: nand: refactor scanning code
A few pieces of code are unnecessarily duplicated. For easier
maintenance, we should fix this.
This should have no functional effect.
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at intel.com>
---
drivers/mtd/nand/nand_bbt.c | 26 +++++++-------------------
1 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index c488bcb..cbf9b69 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -306,28 +306,16 @@ static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
ops.ooboffs = 0;
ops.ooblen = mtd->oobsize;
-
while (len > 0) {
- if (len <= mtd->writesize) {
- ops.oobbuf = buf + len;
- ops.datbuf = buf;
- ops.len = len;
- res = mtd->read_oob(mtd, offs, &ops);
-
- /* Ignore ECC errors when checking for BBM */
- if (res != -EUCLEAN && res != -EBADMSG)
- return res;
- return 0;
- } else {
- ops.oobbuf = buf + mtd->writesize;
- ops.datbuf = buf;
- ops.len = mtd->writesize;
- res = mtd->read_oob(mtd, offs, &ops);
+ ops.datbuf = buf;
+ ops.len = min(len, (size_t)mtd->writesize);
+ ops.oobbuf = buf + ops.len;
- /* Ignore ECC errors when checking for BBM */
- if (res && res != -EUCLEAN && res != -EBADMSG)
- return res;
- }
+ res = mtd->read_oob(mtd, offs, &ops);
+
+ /* Ignore ECC errors when checking for BBM */
+ if (res && res != -EUCLEAN && res != -EBADMSG)
+ return res;
buf += mtd->oobsize + mtd->writesize;
len -= mtd->writesize;
More information about the linux-mtd-cvs
mailing list