mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
3e2b82b907
commit
105513cc4a
|
@ -306,28 +306,16 @@ static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
||||||
ops.ooboffs = 0;
|
ops.ooboffs = 0;
|
||||||
ops.ooblen = mtd->oobsize;
|
ops.ooblen = mtd->oobsize;
|
||||||
|
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
if (len <= mtd->writesize) {
|
ops.datbuf = buf;
|
||||||
ops.oobbuf = buf + len;
|
ops.len = min(len, (size_t)mtd->writesize);
|
||||||
ops.datbuf = buf;
|
ops.oobbuf = buf + ops.len;
|
||||||
ops.len = len;
|
|
||||||
res = mtd->read_oob(mtd, offs, &ops);
|
|
||||||
|
|
||||||
/* Ignore ECC errors when checking for BBM */
|
res = mtd->read_oob(mtd, offs, &ops);
|
||||||
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 */
|
/* Ignore ECC errors when checking for BBM */
|
||||||
if (res && res != -EUCLEAN && res != -EBADMSG)
|
if (res && res != -EUCLEAN && res != -EBADMSG)
|
||||||
return res;
|
return res;
|
||||||
}
|
|
||||||
|
|
||||||
buf += mtd->oobsize + mtd->writesize;
|
buf += mtd->oobsize + mtd->writesize;
|
||||||
len -= mtd->writesize;
|
len -= mtd->writesize;
|
||||||
|
|
Loading…
Reference in New Issue