[NAND flash driver] What would mtd do if read returns -EBADMSG (ecc failed)

Artem Bityutskiy dedekind at infradead.org
Tue Oct 21 02:21:59 EDT 2008


On Tue, 2008-10-21 at 14:11 +0800, Du Zhongdong wrote:
> Hi,
> 
> I'm doing a NAND flash driver, and I suppose if ecc cannot be
> corrected while read something from NAND flash, that block should be
> marked bad, is that right?
> 
> Reading through nand_base.c I notice that mtd->read = nand_read;
> nand_read() [MTD Interface] calls nand_do_read_ops() [Internal] to do
> the work,  and in nand_do_read_ops():
>         if (mtd->ecc_stats.failed - stats.failed)
> 		return -EBADMSG;
> -EBADMSG then is returned to the MTD layer. I tried to trace this
> information in the MTD code, but there seems to be so many and I
> cannot be sure how MTD handles this "-EBADMSG".  Any help or
> information is appreciated.

Hi, -EBADMSG means an uncorrectable ECC error. MTD layer user should
treat it like "MTD returned some data, but it is probably corrupted,
because there was an uncorrectable ECC error".

Glance drivers/mtd/ubi/io.c if you are interested about users which
handle this -EBADMSG.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list