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 1/3] mtd: create per-device and module-scope debugfs entries
Date: Sat, 20 May 2017 18:21:02 +0200 [thread overview]
Message-ID: <20170520182102.504f1372@bbrezillon> (raw)
In-Reply-To: <20170520152428.9184-2-mrugiero@gmail.com>
Le Sat, 20 May 2017 12:24:26 -0300,
"Mario J. Rugiero" <mrugiero@gmail.com> a écrit :
I'd like to have a bit more details explaining why you want to do that.
Something like:
"
Several MTD drivers are currently creating their own debugfs directory
at the root of the debugfs filesystem. Create an mtd directory and one
subdirectory per MTD device so that specific MTD drivers or sub-layers
(NAND, SPI-NOR, ...) can add their own debugfs files under a well known
directory instead of spreading them over the debugfs tree.
"
> Signed-off-by: Mario J. Rugiero <mrugiero@gmail.com>
You forgot to add my Ack here.
> ---
There should be a changelog here, or in the cover letter describing the
evolution of this patch.
> drivers/mtd/mtdcore.c | 17 +++++++++++++++++
> drivers/mtd/mtdcore.h | 2 ++
> include/linux/mtd/mtd.h | 10 ++++++++++
> 3 files changed, 29 insertions(+)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 1517da3ddd7d..461e8139ac2d 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -40,6 +40,7 @@
> #include <linux/slab.h>
> #include <linux/reboot.h>
> #include <linux/leds.h>
> +#include <linux/debugfs.h>
>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/partitions.h>
> @@ -662,6 +663,8 @@ static void mtd_set_dev_defaults(struct mtd_info *mtd)
> }
> }
>
> +static struct dentry *dfs_dir_mtd;
> +
> /**
> * mtd_device_parse_register - parse partitions and register an MTD device.
> *
> @@ -701,6 +704,10 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
>
> mtd_set_dev_defaults(mtd);
>
> + mtd->dbg.dfs_dir = debugfs_create_dir(mtd->name, dfs_dir_mtd);
> + if (IS_ERR(mtd->dbg.dfs_dir))
> + mtd->dbg.dfs_dir = NULL;
> +
> memset(&parsed, 0, sizeof(parsed));
>
> ret = parse_mtd_partitions(mtd, types, &parsed, parser_data);
> @@ -740,6 +747,8 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
> out:
> /* Cleanup any parsed partitions */
> mtd_part_parser_cleanup(&parsed);
> + if (ret)
> + debugfs_remove_recursive(mtd->dbg.dfs_dir);
> return ret;
> }
> EXPORT_SYMBOL_GPL(mtd_device_parse_register);
> @@ -754,6 +763,8 @@ int mtd_device_unregister(struct mtd_info *master)
> {
> int err;
>
> + debugfs_remove_recursive(master->dbg.dfs_dir);
> +
> if (master->_reboot)
> unregister_reboot_notifier(&master->reboot_notifier);
>
> @@ -1807,6 +1818,10 @@ static int __init init_mtd(void)
>
> proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
>
> + dfs_dir_mtd = debugfs_create_dir("mtd", NULL);
> + if (IS_ERR(dfs_dir_mtd))
> + dfs_dir_mtd = NULL;
> +
> ret = init_mtdchar();
> if (ret)
> goto out_procfs;
> @@ -1816,6 +1831,7 @@ static int __init init_mtd(void)
> out_procfs:
> if (proc_mtd)
> remove_proc_entry("mtd", NULL);
> + debugfs_remove(dfs_dir_mtd);
> bdi_put(mtd_bdi);
> err_bdi:
> class_unregister(&mtd_class);
> @@ -1826,6 +1842,7 @@ static int __init init_mtd(void)
>
> static void __exit cleanup_mtd(void)
> {
> + debugfs_remove_recursive(dfs_dir_mtd);
> cleanup_mtdchar();
> if (proc_mtd)
> remove_proc_entry("mtd", NULL);
> diff --git a/drivers/mtd/mtdcore.h b/drivers/mtd/mtdcore.h
> index 55fdb8e1fd2a..b5d095d24087 100644
> --- a/drivers/mtd/mtdcore.h
> +++ b/drivers/mtd/mtdcore.h
> @@ -19,6 +19,8 @@ int parse_mtd_partitions(struct mtd_info *master, const char * const *types,
>
> void mtd_part_parser_cleanup(struct mtd_partitions *parts);
>
> +extern struct dentry *debug_mtd;
> +
> int __init init_mtdchar(void);
> void __exit cleanup_mtdchar(void);
>
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index f8a2ef239c60..6cd0f6b7658b 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -206,6 +206,15 @@ struct mtd_pairing_scheme {
>
> struct module; /* only needed for owner field in mtd_info */
>
> +/**
> + * struct mtd_debug_info - debugging information for an MTD device.
> + *
> + * @dfs_dir: direntry object of the MTD device debugfs directory
> + */
> +struct mtd_debug_info {
> + struct dentry *dfs_dir;
> +};
> +
> struct mtd_info {
> u_char type;
> uint32_t flags;
> @@ -346,6 +355,7 @@ struct mtd_info {
> struct module *owner;
> struct device dev;
> int usecount;
> + struct mtd_debug_info dbg;
> };
>
> int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
next prev parent reply other threads:[~2017-05-20 16:21 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
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 ` Boris Brezillon [this message]
2017-05-20 16:41 ` [PATCH 1/3] mtd: create per-device and module-scope debugfs entries 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=20170520182102.504f1372@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox