Thomas Gleixner wrote: : > > Rename nand_read_ecc to do_nand_read_ecc and add an flag argument. Look > at the erase function, where we have the additional argument for > allowbbt. > flag bits: 0-7 tolerable errors > 8 do not get chip > or something like that. > Create a new wrapper function nand_read_ecc which calls do_nand_read_ecc > with flags = 0xff. Depending on this argument we grab the device and > release it on the end and react on the error check. > The same call can be done from erase in the failure path. > > To make this actually work we should add a member like > int (*ext_errchk) (.....) > which is checked in the error path > if (this->ext_errchk) { > res = this->ext_errchk(....); > } > This is a board supplied function, as the board driver knows how much > errors are acceptable. We return the number of corrected bits anyway in > the correct_data() function, but we check only for -1 at the moment. > An additional check does not hurt here, as we are in the slow path > again. We check the return value of correct_data() for > (res == -1 || res > flags & 0xff) which ensures in the normal case this > tolerance will never bite us, as error correction of 256 bits is unreal. > > Hope that helps. I think this will make the code not uglier than it is > anyway and keeps it nicely dependend on the board drivers featurelist. Attached is a patch that I think implements what you described. Please let me know if I've missed anything or gone astray in the details. Note: I changed a few literals to defined symbols in 'nand_base.c'. Please let me know if you would prefer this in a separate patch (or not at all). Thank you, d.marlin =========