Messages in this thread | | | Date | Wed, 22 Mar 2017 22:12:16 +0100 | From | Boris Brezillon <> | Subject | Re: [PATCH v2 12/53] mtd: nand: denali: support HW_ECC_FIXUP capability |
| |
On Wed, 22 Mar 2017 23:07:19 +0900 Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> +static int denali_hw_ecc_fixup(struct mtd_info *mtd, > + struct denali_nand_info *denali) > +{ > + int bank = denali->flash_bank; > + uint32_t ecc_cor; > + unsigned int max_bitflips; > + > + ecc_cor = ioread32(denali->flash_reg + ECC_COR_INFO(bank)); > + ecc_cor >>= ECC_COR_INFO__SHIFT(bank); > + > + if (ecc_cor & ECC_COR_INFO__UNCOR_ERR) > + return -EBADMSG;
As previously mentioned, just increment ecc_stats.failed.
> + > + max_bitflips = ecc_cor & ECC_COR_INFO__MAX_ERRORS; > + > + /* > + * The register holds the maximum of the number of corrected bitflips > + * per sector. This can be returned from ecc->read_page() as-is. > + * Unfortunately, we can not know the total number of corrected bits > + * in the page. mtd->ecc_stats.corrected is compromised here. > + */ > + mtd->ecc_stats.corrected += max_bitflips; > + > + return max_bitflips; > +}
| |