[PATCH] MTD: treat any negative return value from correct() as an error

Matt Reimer mattjreimer at gmail.com
Sat Oct 20 12:37:16 EDT 2007


On 10/20/07, Jörn Engel <joern at logfs.org> wrote:
> On Wed, 17 October 2007 14:33:23 -0700, mattjreimer at gmail.com wrote:
> >
> > Treat any negative return value from a NAND driver's correct() function
> > as a failure, rather than just -1. Some drivers (e.g. diskonchip) can
> > return error values such as -EIO, which ended up being treated as the
> > number of bits corrected, which in turn resulted in nand_do_read_ops()
> > returning -EUCLEAN rather than -EBADMSG.
>
> What an interesting patch.
>
> NACK on patch description.  Several things are wrong with this:
> o -EIO shouldn't become -EBADMSG any more than -EUCLEAN.  It should
>   remain -EIO and nothing else.

My mistake: I did most of this analysis in the 2.6.21 code, where
cafe_ecc.c:cafe_correct_ecc() did return -EIO, not diskonchip.

But as for the rest of the description, I'm just reading the code
that's there. An error return from ecc.correct bumps stats.failed,
which in nand_do_read_ops does become -EBADMSG:

        if (mtd->ecc_stats.failed - stats.failed)
                return -EBADMSG;

        return  mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0;

So I was just following what I found there, assuming it was standard practice.

> o I cannot see how diskonchip can return -EIO.  Only -ERANGE.

Again, my bad; I was confusing it with an earlier version of
cafe_ecc.c (which I see now didn't pass -EIO up all the way).

Matt



More information about the linux-mtd mailing list