abuse of nand_correct_data in tmio_nand driver

vimal singh vimal.newwork at gmail.com
Sun Jul 26 09:03:05 EDT 2009


On Thu, Jul 23, 2009 at 8:41 PM, Atsushi Nemoto<anemo at mba.ocn.ne.jp> wrote:
> On Thu, 23 Jul 2009 12:34:43 +0530, vimal singh <vimal.newwork at gmail.com> wrote:
>> > OK, but I still feel duplicating nand_ecc code is not so good.  How
>> > about splitting nand_correct_data into two parts?  A pure calculation
>> > function and a wrapper for mtd interface.  Like this:
>>
>> But I do not see any thing extra, which you achieve from this
>> wrapper...  Is this a prototype, and you want to handle above scenario
>> in this wrapper (calling 'nand_correct_data' multiple times based on
>> something, probably 'ecc.bytes')?
>
> Yes, if we have __nand_correct_data(buf, read_ecc, calc_ecc, eccsize)
> which do job based on its eccsize argument, the ecc.correct function
> of the tmio_nand driver can be implemented like this:
>
> int tmio_nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
>                unsigned char *read_ecc, unsigned char *calc_ecc)
> {
>        int r0, r1;
>
>        /* assume ecc.size = 512 and ecc.bytes = 6 */
>        r0 = __nand_correct_data(buf, read_ecc, calc_ecc, 256);
>        if (r0 < 0)
>                return r0;
>        r1 = __nand_correct_data(buf + 256, read_ecc + 3, calc_ecc + 3, 256);
>        if (r1 < 0)
>                return r1;
>        return r0 | r1;

Better 'r0 + r1', returned value should represent number of error bits
corrected.


After fixing above comment:

Acked-by: Vimal Singh <vimalsingh at ti.com>


---
Regards,
\/ | |\/| /-\ |_

____      __o
------   -\<,
-----  ( )/ ( )



More information about the linux-mtd mailing list