From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Mario J. Rugiero" <mrugiero@gmail.com>
Cc: linux-mtd@lists.infradead.org, computersforpeace@gmail.com,
marek.vasut@gmail.com, richard@nod.at,
cyrille.pitchen@wedev4u.fr
Subject: Re: [PATCH 3/3] mtd: nand: add option to ignore bad blocks when erasing, opt-in through debugfs
Date: Sat, 20 May 2017 19:54:33 +0200 [thread overview]
Message-ID: <20170520195433.2f1970a9@bbrezillon> (raw)
In-Reply-To: <20170520152428.9184-4-mrugiero@gmail.com>
Le Sat, 20 May 2017 12:24:28 -0300,
"Mario J. Rugiero" <mrugiero@gmail.com> a écrit :
And again, pleases add a commit message.
> Signed-off-by: Mario J. Rugiero <mrugiero@gmail.com>
> ---
> drivers/mtd/nand/nand_base.c | 26 ++++++++++++++++++++++----
> include/linux/mtd/nand.h | 12 ++++++++++++
> 2 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 52a257e12026..8cffea38a642 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -47,6 +47,7 @@
> #include <linux/io.h>
> #include <linux/mtd/partitions.h>
> #include <linux/of.h>
> +#include <linux/debugfs.h>
>
> static int nand_get_device(struct mtd_info *mtd, int new_state);
>
> @@ -3209,10 +3210,15 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
> /* Check if we have a bad block, we do not erase bad blocks! */
> if (nand_block_checkbad(mtd, ((loff_t) page) <<
> chip->page_shift, allowbbt)) {
> - pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
> - __func__, page);
> - instr->state = MTD_ERASE_FAILED;
> - goto erase_exit;
> + if (!chip->dbg.scrub_enabled) {
> + pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
> + __func__, page);
> + instr->state = MTD_ERASE_FAILED;
> + goto erase_exit;
> + } else {
> + pr_warn("%s: erasing a bad block at page 0x%08x\n",
> + __func__, page);
> + }
> }
>
> /*
> @@ -4931,6 +4937,18 @@ int nand_device_register(struct mtd_info *mtd,
> int defnr_parts)
> {
> int ret = nand_device_register(mtd, defparts, defnr_parts);
> + struct nand_debug_info *dbg;
> +
> + if (!ret) {
> + dbg = &mtd_to_nand(mtd)->dbg;
> + dbg->scrub_enabled = false;
> + dbg->dfs_scrub_enabled = debugfs_create_bool("scrub_enabled",
Or just "scrub", the enable/disable status is reflected by the value
exposed by the file.
BTW, not sure scrub is clear enough, how about "allow-bad-block-erase"?
> + 0600,
> + mtd->dbg.dfs_dir,
> + &dbg->scrub_enabled);
> + if (IS_ERR(dbg->dfs_scrub_enabled))
> + dbg->dfs_scrub_enabled = NULL;
> + }
I prefer:
struct nand_debug_info *dbg;
int ret;
ret = mtd_device_register(mtd, defparts, defnr_parts);
if (ret)
return ret;
dbg = &chip->dbg;
dbg->scrub_enabled = false;
dbg->dfs_scrub_enabled = debugfs_create_bool("scrub", 0600, mtd->dbg.dfs_dir,
&dbg->scrub_enabled);
if (IS_ERR(dbg->dfs_scrub_enabled))
dbg->dfs_scrub_enabled = NULL;
return 0;
This way the error path is easily identified and you don't have to add
an indentation level for the normal path.
}
next prev parent reply other threads:[~2017-05-20 17:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 15:24 [PATCH 0/3] mtd: nand: allow force erasing of bad blocks through debugfs entry Mario J. Rugiero
2017-05-20 15:24 ` [PATCH 1/3] mtd: create per-device and module-scope debugfs entries Mario J. Rugiero
2017-05-20 15:24 ` [PATCH 2/3] mtd: nand: create a wrapper for mtd_device_register for NAND specific initialization Mario J. Rugiero
2017-05-20 15:24 ` [PATCH 3/3] mtd: nand: add option to ignore bad blocks when erasing, opt-in through debugfs Mario J. Rugiero
2017-05-20 17:54 ` Boris Brezillon [this message]
2017-05-20 17:38 ` [PATCH 2/3] mtd: nand: create a wrapper for mtd_device_register for NAND specific initialization Boris Brezillon
2017-05-20 17:44 ` Boris Brezillon
2017-05-20 17:46 ` Boris Brezillon
2017-05-20 17:56 ` Boris Brezillon
2017-05-20 16:21 ` [PATCH 1/3] mtd: create per-device and module-scope debugfs entries Boris Brezillon
2017-05-20 16:41 ` Mario Rugiero
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=20170520195433.2f1970a9@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=mrugiero@gmail.com \
--cc=richard@nod.at \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.