Proposal: allow reading oob with AUTOPLACE
Hi folks
As has been discussed in various places, it would be nice to be able to read oob with AUTOPLACE, without reading the whole data page too. At present there is no way to do this.
Having this capability is quite important to YAFFS2 since it allows the tags (in oob) to be scanned without having to do the extra (useless) work of dummy-reading the data. Currently people have to manually fiddle around to get the required semantics.
There are three ways I can see to achieve this:
1) Change the semantics of read_oob(). That would work, but would break anyone expecting read_oob() to have its current semantics of reading raw.
2) Change read_oob() to take an oobsel argument to allow reading raw or AUTOPLACE or whatever. That would break some code, but very little. At least it would be obvious where something needs fixing (whereas (1) does not make it obvious).
3) Change read_ecc() to allow passing in a NULL data buf pointer to indicate that only the oob should be read.
Personally, I think 2 is neatest from an interface perspective, but 3 breaks the least and 1 is the worst because semantics change in an uncontrolled way. However, this is a personal taste issue and I will be happy with any solution that gives the function.
I have below an**untested** patch for option 3 - sorry folk; no hw == no test. I wrote this with the intent of seeing how traumatic the changes might be, rather than try build shippable code.
I expect the patch does not conform to guidelines, but I hope not to get a public flogging.
diff /opt/mtd_virgin/drivers/mtd/nand/nand_base.c /opt/mtd/drivers/mtd/nand/nand_base.c 1118a1119
Quoted 1 line
int
oob_only,oob_once;
1147a1149,1150
Quoted 2 lines
oob_once =
oob_only= (!buf); /* buf is NULL, so only reading OOB */
1174c1177
< while (read < len) {
---
Quoted 1 line
while (read < len ||
oob_once) {
1200c1203
< this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
---
Quoted 1 line
this->cmdfunc (mtd, (
oob_only) ?NAND_CMD_READOOB:
NAND_CMD_READ0, 0x00, page);1201a1205
Quoted 1 line
oob_once = 0;
1208a1213
Quoted 1 line
1210a1216,1218
Quoted 3 lines
if(oob_only)
gotoread_oob_data;
1256a1265
Quoted 1 line
read_oob_data:
1260c1269
< if (!compareecc)
---
Quoted 1 line
if (!compareecc ||
oob_only)