Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 105513cc authored by Brian Norris's avatar Brian Norris Committed by Artem Bityutskiy
Browse files

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: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@intel.com>
parent 3e2b82b9
Loading
Loading
Loading
Loading
+8 −20
Original line number Diff line number Diff line
@@ -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);
		ops.len = min(len, (size_t)mtd->writesize);
		ops.oobbuf = buf + ops.len;

			/* 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);

		/* Ignore ECC errors when checking for BBM */
		if (res && res != -EUCLEAN && res != -EBADMSG)
			return res;
		}

		buf += mtd->oobsize + mtd->writesize;
		len -= mtd->writesize;