From: Boris Brezillon <boris.brezillon@collabora.com>
To: Zhuohao Lee <zhuohao@chromium.org>
Cc: drinkcat@chromium.org, bbrezillon@kernel.org, richard@nod.at,
briannorris@chromium.org, marek.vasut@gmail.com,
linux-mtd@lists.infradead.org, computersforpeace@gmail.com,
dwmw2@infradead.org
Subject: Re: [PATCH v4 1/2] mtd: mtdcore: add debugfs nodes for querying the flash name and id
Date: Sat, 1 Jun 2019 10:09:20 +0200 [thread overview]
Message-ID: <20190601100920.44ec2a3e@collabora.com> (raw)
In-Reply-To: <20190530152101.176431-1-zhuohao@chromium.org>
On Thu, 30 May 2019 23:21:00 +0800
Zhuohao Lee <zhuohao@chromium.org> wrote:
> Currently, we don't have vfs nodes for querying the underlying flash name
> and flash id. This information is important especially when we want to
> know the flash detail of the defective system. In order to support the
> query, we add mtd_debugfs_populate() to create two debugfs nodes
> (ie. partname and partid). The upper driver can assign the pointer to
> partname and partid before calling mtd_device_register().
>
> Signed-off-by: Zhuohao Lee <zhuohao@chromium.org>
> ---
> Changes in V4:
> - Separate the change to two patches. The first patch is adding the general
> handling for the partname and partid in the mtdcore.c. The second patch
> is enabling the two debugfs nodes for spi-nor.
> - Previous discussion: https://patchwork.ozlabs.org/patch/1097377/
> Changes in v3:
> - Add partname and partid to mtd.h and create debugfs inside mtdcore.c
> - Previous discussion: https://patchwork.ozlabs.org/patch/1095731/
> Changes in v2:
> - Change to use debugfs to output flash name and id
> - Previous discussion: https://patchwork.ozlabs.org/patch/1067763/
> ---
> drivers/mtd/mtdcore.c | 72 +++++++++++++++++++++++++++++++++++++++++
> include/linux/mtd/mtd.h | 4 +++
> 2 files changed, 76 insertions(+)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 3ef01baef9b6..b53b40cb2f04 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -357,6 +357,75 @@ static const struct device_type mtd_devtype = {
> .release = mtd_release,
> };
>
> +static int mtd_partid_show(struct seq_file *s, void *p)
> +{
> + struct mtd_info *mtd = s->private;
> +
> + if (!mtd->dbg.partid)
> + return 0;
> +
> + seq_printf(s, "%s\n", mtd->dbg.partid);
> +
> + return 0;
> +}
> +
> +static int mtd_partid_debugfs_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, mtd_partid_show, inode->i_private);
> +}
> +
> +static const struct file_operations mtd_partid_debug_fops = {
> + .open = mtd_partid_debugfs_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +static int mtd_partname_show(struct seq_file *s, void *p)
> +{
> + struct mtd_info *mtd = s->private;
> +
> + if (!mtd->dbg.partname)
> + return 0;
> +
> + seq_printf(s, "%s\n", mtd->dbg.partname);
> +
> + return 0;
> +}
> +
> +static int mtd_partname_debugfs_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, mtd_partname_show, inode->i_private);
> +}
> +
> +static const struct file_operations mtd_partname_debug_fops = {
> + .open = mtd_partname_debugfs_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +static int mtd_debugfs_populate(struct mtd_info *mtd)
> +{
> + struct dentry *root = mtd->dbg.dfs_dir;
> + struct dentry *dent;
> +
> + dent = debugfs_create_file("partid", S_IRUSR, root, mtd,
> + &mtd_partid_debug_fops);
> + if (IS_ERR_OR_NULL(dent)) {
> + pr_err("cannot create debugfs entry for partid\n");
> + return -ENODEV;
> + }
> + dent = debugfs_create_file("partname", S_IRUSR, root, mtd,
> + &mtd_partname_debug_fops);
> + if (IS_ERR_OR_NULL(dent)) {
> + pr_err("cannot create debugfs entry for partname\n");
> + return -ENODEV;
> + }
> +
> + return 0;
> +}
> +
> #ifndef CONFIG_MMU
> unsigned mtd_mmap_capabilities(struct mtd_info *mtd)
> {
> @@ -626,6 +695,9 @@ int add_mtd_device(struct mtd_info *mtd)
> if (IS_ERR_OR_NULL(mtd->dbg.dfs_dir)) {
> pr_debug("mtd device %s won't show data in debugfs\n",
> dev_name(&mtd->dev));
> + } else if (mtd_debugfs_populate(mtd)) {
> + pr_debug("mtd device %s can't create debugfs\n",
s/create/populate/
Also, not sure we really need a dbg message here since you already have
error messages in mtd_debugfs_populate().
One last thing: can we move the debugfs_create_dir() call to
mtd_debugfs_populate() so all you have to do from add_mtd_device()
is call mtd_debugfs_populate().
Once addressed, you can add
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> + dev_name(&mtd->dev));
> }
> }
>
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 677768b21a1d..c20f53c77899 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -203,6 +203,10 @@ struct module; /* only needed for owner field in mtd_info */
> */
> struct mtd_debug_info {
> struct dentry *dfs_dir;
> +
> + /* debugfs stuff starts here */
> + const char *partname;
> + const char *partid;
> };
>
> struct mtd_info {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2019-06-01 8:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 15:21 [PATCH v4 1/2] mtd: mtdcore: add debugfs nodes for querying the flash name and id Zhuohao Lee
2019-05-30 15:21 ` [PATCH v4 2/2] mtd: spi-nor: enable the debugfs for the partname and partid Zhuohao Lee
2019-06-01 8:14 ` Boris Brezillon
2019-06-01 8:09 ` Boris Brezillon [this message]
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=20190601100920.44ec2a3e@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=bbrezillon@kernel.org \
--cc=briannorris@chromium.org \
--cc=computersforpeace@gmail.com \
--cc=drinkcat@chromium.org \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
--cc=zhuohao@chromium.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 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.