Skip to content

Commit b64d39d

Browse files
maximlevitskyDavid Woodhouse
authored andcommitted
mtd: nand: make reads using MTD_OOB_RAW affect only ECC validation
This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer. This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user. Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 782ce79 commit b64d39d

3 files changed

Lines changed: 30 additions & 19 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,18 +1474,13 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
14741474

14751475
if (unlikely(oob)) {
14761476

1477-
/* Raw mode does data:oob:data:oob */
1478-
if (ops->mode != MTD_OOB_RAW) {
1479-
int toread = min(oobreadlen,
1480-
max_oobsize);
1481-
if (toread) {
1482-
oob = nand_transfer_oob(chip,
1483-
oob, ops, toread);
1484-
oobreadlen -= toread;
1485-
}
1486-
} else
1487-
buf = nand_transfer_oob(chip,
1488-
buf, ops, mtd->oobsize);
1477+
int toread = min(oobreadlen, max_oobsize);
1478+
1479+
if (toread) {
1480+
oob = nand_transfer_oob(chip,
1481+
oob, ops, toread);
1482+
oobreadlen -= toread;
1483+
}
14891484
}
14901485

14911486
if (!(chip->options & NAND_NO_READRDY)) {

‎drivers/mtd/nand/nand_bbt.c‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,33 @@ static int scan_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
237237
size_t len)
238238
{
239239
struct mtd_oob_ops ops;
240+
int res;
240241

241242
ops.mode = MTD_OOB_RAW;
242243
ops.ooboffs = 0;
243244
ops.ooblen = mtd->oobsize;
244-
ops.oobbuf = buf;
245-
ops.datbuf = buf;
246-
ops.len = len;
247245

248-
return mtd->read_oob(mtd, offs, &ops);
246+
247+
while (len > 0) {
248+
if (len <= mtd->writesize) {
249+
ops.oobbuf = buf + len;
250+
ops.datbuf = buf;
251+
ops.len = len;
252+
return mtd->read_oob(mtd, offs, &ops);
253+
} else {
254+
ops.oobbuf = buf + mtd->writesize;
255+
ops.datbuf = buf;
256+
ops.len = mtd->writesize;
257+
res = mtd->read_oob(mtd, offs, &ops);
258+
259+
if (res)
260+
return res;
261+
}
262+
263+
buf += mtd->oobsize + mtd->writesize;
264+
len -= mtd->writesize;
265+
}
266+
return 0;
249267
}
250268

251269
/*

‎include/linux/mtd/mtd.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ struct mtd_erase_region_info {
6060
* MTD_OOB_PLACE: oob data are placed at the given offset
6161
* MTD_OOB_AUTO: oob data are automatically placed at the free areas
6262
* which are defined by the ecclayout
63-
* MTD_OOB_RAW: mode to read raw data+oob in one chunk. The oob data
64-
* is inserted into the data. Thats a raw image of the
65-
* flash contents.
63+
* MTD_OOB_RAW: mode to read oob and data without doing ECC checking
6664
*/
6765
typedef enum {
6866
MTD_OOB_PLACE,

0 commit comments

Comments
 (0)