On 01/09/2012 06:24 AM, Prabhakar Kushwaha wrote: > @@ -215,12 +215,15 @@ static int is_blank(struct mtd_info *mtd, unsigned int > bufnum) > static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, > u32 *eccstat, unsigned int bufnum) > { > + struct nand_chip *chip = mtd->priv; > + int bufperpage = mtd->writesize / chip->ecc.size; > + int eccbuf_num = bufnum + (bufnum / bufperpage) * bufperpage;
This is unnecessarily complicated (and introduces two more, dependent, runtime divisions). I don't think there are any changes required in this function. You're awkwardly compensating for the fact that the caller hasn't been updated for the new definition of bufnum. bufperpage used in fsl_ifc_run_command should be doubled to account for the OOB buffers. We should probably rename it from "buf" to something else (chunk? subpage?) to avoid confusion with bufnum_mask, which refers to page-sized buffers. > u32 reg = eccstat[bufnum / 4]; > int errors = (reg >> ((3 - bufnum % 4) * 8)) & 15; > > if (errors == 15) { /* uncorrectable */ > /* Blank pages fail hw ECC checks */ > - if (is_blank(mtd, bufnum)) > + if (is_blank(mtd, eccbuf_num)) > return 1; > > /* > @@ -273,7 +276,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) > dev_err(priv->dev, "NAND Flash Write Protect Error\n"); > > if (nctrl->eccread) { > - int bufperpage = mtd->writesize / 512; > + int bufperpage = mtd->writesize / chip->ecc.size; > int bufnum = (nctrl->page & priv->bufnum_mask) * bufperpage; > int bufnum_end = bufnum + bufperpage - 1; > Again, please calculate bufperpage (chunksperpage? subsperpage? perbuf?) at driver init, as is done with bufnum_mask. -Scott _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev