nandwrite autoplace for real
Todd Poynor
tpoynor at mvista.com
Tue Nov 22 21:47:38 EST 2005
nand_write_ecc() treats OOB autoplace as "take a string of fs-supplied
bytes (without ECC bytes, bad block marker, etc.) and place them
sequentially in free OOB positions" (implemented in
nand_prepare_oobbuf).
nandwrite -a, on the other hand, requires the input to have the OOB data
already autoplaced (skipping ECC bytes, etc.), and copies the free bytes
position-by-position from input to OOB.
The former definition seems much more useful. Any objection to the
following patch? Is anything using the current definition?
BTW, I couldn't make heads or tails of the non-autoplace oob writing
code, which uses the number of ECC bytes as the starting position to
copy fs data from and to.
If I'm misunderstanding any of this I'd appreciate the clue bat. -- Todd
Index: util/nandwrite.c
===================================================================
RCS file: /home/cvs/mtd/util/nandwrite.c,v
retrieving revision 1.32
diff -u -r1.32 nandwrite.c
--- util/nandwrite.c 7 Nov 2005 11:15:13 -0000 1.32
+++ util/nandwrite.c 23 Nov 2005 02:20:36 -0000
@@ -401,13 +401,15 @@
* such as the layout used by diskonchip.c
*/
if (!oobinfochanged && (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE)) {
- for (i = 0;old_oobinfo.oobfree[i][1]; i++) {
- /* Set the reserved bytes to 0xff */
+ int src;
+
+ for (src = 0, i = 0;old_oobinfo.oobfree[i][1]; i++) {
start = old_oobinfo.oobfree[i][0];
len = old_oobinfo.oobfree[i][1];
memcpy(oobbuf + start,
- oobreadbuf + start,
+ oobreadbuf + src,
len);
+ src += len;
}
} else {
/* Set at least the ecc byte positions to 0xff */
More information about the linux-mtd
mailing list