From: Brian Norris <computersforpeace@gmail.com>
To: Josh Wu <josh.wu@atmel.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: atmel_nand: NFC: fix mtd_nandbiterrs.ko test fail when using sram write
Date: Mon, 4 Aug 2014 14:22:59 -0700 [thread overview]
Message-ID: <20140804212259.GA3711@ld-irv-0074> (raw)
In-Reply-To: <1406021138-5545-1-git-send-email-josh.wu@atmel.com>
On Tue, Jul 22, 2014 at 05:25:38PM +0800, Josh Wu wrote:
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 33826a0..012d687 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -1913,15 +1913,13 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
> if (offset || (data_len < mtd->writesize))
> return -EINVAL;
>
> - cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
> - len = mtd->writesize;
> -
> - if (unlikely(raw)) {
> - len += mtd->oobsize;
> - nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
> - } else
> - nfc_writel(host->nfc->hsmc_regs, CFG, cfg & ~NFC_CFG_WSPARE);
> + if (data_len > mtd->writesize) {
> + dev_err(host->dev, "data_len: %d should not bigger than mtd->writesize: %d!\n",
"should not be"
> + data_len, mtd->writesize);
> + return -EINVAL;
> + }
The NAND layer guarantees that 'write_page' will never have to write
more than 1 page (mtd->writesize), so the above block seems unnecessary.
Drop it?
>
> + len = mtd->writesize;
> /* Copy page data to sram that will write to nand via NFC */
> if (use_dma) {
> if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0)
> @@ -1931,6 +1929,15 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
> memcpy32_toio(sram, buf, len);
> }
>
> + cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
> + if (unlikely(raw) && oob_required) {
> + memcpy32_toio(sram + len, chip->oob_poi, mtd->oobsize);
> + len += mtd->oobsize;
> + nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
> + } else {
> + nfc_writel(host->nfc->hsmc_regs, CFG, cfg & ~NFC_CFG_WSPARE);
> + }
> +
> if (chip->ecc.mode == NAND_ECC_HW && host->has_pmecc)
> /*
> * When use NFC sram, need set up PMECC before send
Brian
next prev parent reply other threads:[~2014-08-04 21:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 9:25 [PATCH] mtd: atmel_nand: NFC: fix mtd_nandbiterrs.ko test fail when using sram write Josh Wu
2014-08-04 21:22 ` Brian Norris [this message]
2014-08-05 10:41 ` Josh Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140804212259.GA3711@ld-irv-0074 \
--to=computersforpeace@gmail.com \
--cc=josh.wu@atmel.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox