aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_bbt.c
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2011-09-07 16:13:28 -0400
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-09-11 09:48:47 -0400
commit105513cc4a25522f959788371bd612f987d4d184 (patch)
treeb106fc56e195d5c883f11c329cf7ffb59e1d83eb /drivers/mtd/nand/nand_bbt.c
parent3e2b82b9073e8bf0b4f359fa3045e81d9fe87f7d (diff)
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@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Diffstat (limited to 'drivers/mtd/nand/nand_bbt.c')
-rw-r--r--drivers/mtd/nand/nand_bbt.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index c488bcb84c90..cbf9b695c6f2 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,
306 ops.ooboffs = 0; 306 ops.ooboffs = 0;
307 ops.ooblen = mtd->oobsize; 307 ops.ooblen = mtd->oobsize;
308 308
309
310 while (len > 0) { 309 while (len > 0) {
311 if (len <= mtd->writesize) { 310 ops.datbuf = buf;
312 ops.oobbuf = buf + len; 311 ops.len = min(len, (size_t)mtd->writesize);
313 ops.datbuf = buf; 312 ops.oobbuf = buf + ops.len;
314 ops.len = len;
315 res = mtd->read_oob(mtd, offs, &ops);
316
317 /* Ignore ECC errors when checking for BBM */
318 if (res != -EUCLEAN && res != -EBADMSG)
319 return res;
320 return 0;
321 } else {
322 ops.oobbuf = buf + mtd->writesize;
323 ops.datbuf = buf;
324 ops.len = mtd->writesize;
325 res = mtd->read_oob(mtd, offs, &ops);
326 313
327 /* Ignore ECC errors when checking for BBM */ 314 res = mtd->read_oob(mtd, offs, &ops);
328 if (res && res != -EUCLEAN && res != -EBADMSG) 315
329 return res; 316 /* Ignore ECC errors when checking for BBM */
330 } 317 if (res && res != -EUCLEAN && res != -EBADMSG)
318 return res;
331 319
332 buf += mtd->oobsize + mtd->writesize; 320 buf += mtd->oobsize + mtd->writesize;
333 len -= mtd->writesize; 321 len -= mtd->writesize;