From: boris.brezillon@free-electrons.com (Boris Brezillon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] mtd: nand: use usual return values for the ->erase() hook
Date: Thu, 30 Nov 2017 21:51:13 +0100 [thread overview]
Message-ID: <20171130215113.458d616f@bbrezillon> (raw)
In-Reply-To: <20171130170132.27522-2-miquel.raynal@free-electrons.com>
On Thu, 30 Nov 2017 18:01:28 +0100
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> Avoid using specific defined values for checking returned status of the
> ->erase() hook. Instead, use usual negative error values on failure,
> zero otherwise.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
> ---
> drivers/mtd/nand/denali.c | 2 +-
> drivers/mtd/nand/docg4.c | 7 ++++++-
> drivers/mtd/nand/nand_base.c | 2 +-
> 3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> index 34008a02ddb0..3e19861a46c6 100644
> --- a/drivers/mtd/nand/denali.c
> +++ b/drivers/mtd/nand/denali.c
> @@ -951,7 +951,7 @@ static int denali_erase(struct mtd_info *mtd, int page)
> irq_status = denali_wait_for_irq(denali,
> INTR__ERASE_COMP | INTR__ERASE_FAIL);
>
> - return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL;
> + return irq_status & INTR__ERASE_COMP ? 0 : -EIO;
> }
>
> static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr,
> diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
> index 2436cbc71662..45c01b4b34c7 100644
> --- a/drivers/mtd/nand/docg4.c
> +++ b/drivers/mtd/nand/docg4.c
> @@ -900,6 +900,7 @@ static int docg4_erase_block(struct mtd_info *mtd, int page)
> struct docg4_priv *doc = nand_get_controller_data(nand);
> void __iomem *docptr = doc->virtadr;
> uint16_t g4_page;
> + int status;
>
> dev_dbg(doc->dev, "%s: page %04x\n", __func__, page);
>
> @@ -939,7 +940,11 @@ static int docg4_erase_block(struct mtd_info *mtd, int page)
> poll_status(doc);
> write_nop(docptr);
>
> - return nand->waitfunc(mtd, nand);
> + status = nand->waitfunc(mtd, nand);
> + if (status < 0)
> + return status;
> +
> + return status & NAND_STATUS_FAIL ? -EIO : 0;
> }
>
> static int write_page(struct mtd_info *mtd, struct nand_chip *nand,
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 630048f5abdc..4d1f2bda6095 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3077,7 +3077,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
> status = chip->erase(mtd, page & chip->pagemask);
>
> /* See if block erase succeeded */
> - if (status & NAND_STATUS_FAIL) {
> + if (status) {
> pr_debug("%s: failed erase, page 0x%08x\n",
> __func__, page);
> instr->state = MTD_ERASE_FAILED;
You forgot to patch single_erase() accordingly.
next prev parent reply other threads:[~2017-11-30 20:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 17:01 [PATCH 0/5] Introduce the new NAND core interface: ->exec_op() Miquel Raynal
2017-11-30 17:01 ` [PATCH 1/5] mtd: nand: use usual return values for the ->erase() hook Miquel Raynal
2017-11-30 20:51 ` Boris Brezillon [this message]
2017-11-30 22:02 ` Miquel RAYNAL
2017-12-01 2:12 ` Masahiro Yamada
2017-12-01 9:39 ` Boris Brezillon
2017-11-30 17:01 ` [PATCH 2/5] mtd: nand: provide several helpers to do common NAND operations Miquel Raynal
2017-12-01 2:38 ` Masahiro Yamada
2017-11-30 17:01 ` [PATCH 3/5] mtd: nand: force drivers to explicitly send READ/PROG commands Miquel Raynal
2017-12-01 2:39 ` Masahiro Yamada
2017-11-30 17:01 ` [PATCH 4/5] mtd: nand: use a static data_interface in the nand_chip structure Miquel Raynal
2017-12-01 9:38 ` Boris Brezillon
2017-11-30 17:01 ` [PATCH 5/5] mtd: nand: add ->exec_op() implementation Miquel Raynal
2017-11-30 20:50 ` Boris Brezillon
2017-11-30 22:25 ` Miquel RAYNAL
2017-12-01 9:50 ` Boris Brezillon
2017-12-01 9:57 ` Miquel RAYNAL
2017-12-01 11:07 ` Boris Brezillon
2017-12-01 9:37 ` [PATCH 0/5] Introduce the new NAND core interface: ->exec_op() Boris Brezillon
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=20171130215113.458d616f@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).