Message ID | 1397504134-32178-5-git-send-email-davidm@egauge.net |
---|---|
State | Rejected |
Headers | show |
On Mon, 2014-04-14 at 13:35 -0600, David Mosberger wrote: > > To avoid unnecessary rewrites, it is necessary to count the number of > actual bitflips that occurred when the NAND_STATUS_REWRITE bit is set. > This patch introduces the extra buffers needed to implement that > counting. The actual counting is in the next patch. I'd suggest to s/the next patch/a subsequent patch/ -- the order of commits in the mainline repo need not strictly follow arbitrary submission sequences > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -3939,13 +3939,24 @@ int nand_scan_tail(struct mtd_info *mtd) > !(chip->bbt_options & NAND_BBT_USE_FLASH)); > > if (!(chip->options & NAND_OWN_BUFFERS)) { > + size_t on_die_bufsz = 0; > + > + if (chip->ecc.mode == NAND_ECC_HW_ON_DIE) > + on_die_bufsz = 2*(mtd->writesize + mtd->oobsize); > + > nbuf = kzalloc(sizeof(*nbuf) + mtd->writesize > - + mtd->oobsize * 3, GFP_KERNEL); > + + mtd->oobsize * 3 + on_die_bufsz, GFP_KERNEL); > if (!nbuf) > return -ENOMEM; > nbuf->ecccalc = (uint8_t *)(nbuf + 1); > nbuf->ecccode = nbuf->ecccalc + mtd->oobsize; > nbuf->databuf = nbuf->ecccode + mtd->oobsize; > + if (chip->ecc.mode == NAND_ECC_HW_ON_DIE) { > + nbuf->chkbuf = (nbuf->databuf + mtd->writesize > + + mtd->oobsize); > + nbuf->rawbuf = (nbuf->chkbuf + mtd->writesize > + + mtd->oobsize); > + } > > chip->buffers = nbuf; > } else { you introduce the 'on_die_bufsz' variable, can you use it (under a more appropriate name then) to first determine the required amount of memory and then have a kzalloc() call with a size spec that is not as complex as the current implementation? independent from this optional style improvement, you should fixup the whitespace issues around operators, and remove the unnecessary parentheses; having the "writesize + oobsize" in another variable might help eliminate more duplication and trim line length, and better reflect how the size calculation and the pointer calculation match each other virtually yours Gerhard Sittig
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 7092875..84409db 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3939,13 +3939,24 @@ int nand_scan_tail(struct mtd_info *mtd) !(chip->bbt_options & NAND_BBT_USE_FLASH)); if (!(chip->options & NAND_OWN_BUFFERS)) { + size_t on_die_bufsz = 0; + + if (chip->ecc.mode == NAND_ECC_HW_ON_DIE) + on_die_bufsz = 2*(mtd->writesize + mtd->oobsize); + nbuf = kzalloc(sizeof(*nbuf) + mtd->writesize - + mtd->oobsize * 3, GFP_KERNEL); + + mtd->oobsize * 3 + on_die_bufsz, GFP_KERNEL); if (!nbuf) return -ENOMEM; nbuf->ecccalc = (uint8_t *)(nbuf + 1); nbuf->ecccode = nbuf->ecccalc + mtd->oobsize; nbuf->databuf = nbuf->ecccode + mtd->oobsize; + if (chip->ecc.mode == NAND_ECC_HW_ON_DIE) { + nbuf->chkbuf = (nbuf->databuf + mtd->writesize + + mtd->oobsize); + nbuf->rawbuf = (nbuf->chkbuf + mtd->writesize + + mtd->oobsize); + } chip->buffers = nbuf; } else { diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index d09f0a0..7725bbc 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -533,6 +533,8 @@ struct nand_buffers { uint8_t *ecccalc; uint8_t *ecccode; uint8_t *databuf; + uint8_t *chkbuf; + uint8_t *rawbuf; }; /**
To avoid unnecessary rewrites, it is necessary to count the number of actual bitflips that occurred when the NAND_STATUS_REWRITE bit is set. This patch introduces the extra buffers needed to implement that counting. The actual counting is in the next patch. Signed-off-by: David Mosberger <davidm@egauge.net> --- drivers/mtd/nand/nand_base.c | 13 ++++++++++++- include/linux/mtd/nand.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-)