The nand driver implements different possibilities for placement of filesystem data in the spare area,
Placement defined by fs driver
Automatic placement
File system drivers can provide a own placement scheme which is used instead of the default placement scheme.
Placement schemes are defined by a nand_oobinfo structure
struct nand_oobinfo { int useecc; int eccbytes; int eccpos[24]; int oobfree[8][2]; };
The calling function provides a pointer to a nand_oobinfo structure which defines the ecc placement. For writes the caller must provide a spare area buffer along with the data buffer. The spare area buffer size is (number of pages) * (size of spare area). For reads the buffer size is (number of pages) * ((size of spare area) + (number of ecc steps per page) * sizeof (int)). The driver stores the result of the ecc check for each tuple in the spare buffer. The storage sequence is
<spare data page 0><ecc result 0>...<ecc result n>
...
<spare data page n><ecc result 0>...<ecc result n>
This is a legacy mode used by YAFFS1.
If the spare area buffer is NULL then only the ECC placement is done according to the given scheme in the nand_oobinfo structure.
Automatic placement uses the built in defaults to place the ecc bytes in the spare area. If filesystem data have to be stored / read into the spare area then the calling function must provide a buffer. The buffer size per page is determined by the oobfree array in the nand_oobinfo structure.
If the spare area buffer is NULL then only the ECC placement is done according to the default builtin scheme.