linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: Create partname and partid debug files for child MTDs
@ 2021-04-30  6:50 Petr Malat
  2021-04-30  7:02 ` Michael Walle
  2021-05-10 10:43 ` Miquel Raynal
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Malat @ 2021-04-30  6:50 UTC (permalink / raw)
  To: linux-mtd
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Petr Malat

Partname and partid are set by the upper driver (spi-nor) on the master
MTD. If this MTD is partitioned and CONFIG_MTD_PARTITIONED_MASTER is
disabled, the master MTD is not instantiated and partname and partid
aren't available to the userspace.

Always read the partname and partid from the master MTD, they describe
the HW, which can't differ between master and its children.

Signed-off-by: Petr Malat <oss@malat.biz>
---
 drivers/mtd/mtdcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 2d6423d89a17..66fa7f702174 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -361,6 +361,7 @@ static struct dentry *dfs_dir_mtd;
 
 static void mtd_debugfs_populate(struct mtd_info *mtd)
 {
+	struct mtd_info *master = mtd_get_master(mtd);
 	struct device *dev = &mtd->dev;
 	struct dentry *root;
 
@@ -370,12 +371,12 @@ static void mtd_debugfs_populate(struct mtd_info *mtd)
 	root = debugfs_create_dir(dev_name(dev), dfs_dir_mtd);
 	mtd->dbg.dfs_dir = root;
 
-	if (mtd->dbg.partid)
-		debugfs_create_file("partid", 0400, root, mtd,
+	if (master->dbg.partid)
+		debugfs_create_file("partid", 0400, root, master,
 				    &mtd_partid_debug_fops);
 
-	if (mtd->dbg.partname)
-		debugfs_create_file("partname", 0400, root, mtd,
+	if (master->dbg.partname)
+		debugfs_create_file("partname", 0400, root, master,
 				    &mtd_partname_debug_fops);
 }
 
-- 
2.20.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: Create partname and partid debug files for child MTDs
  2021-04-30  6:50 [PATCH] mtd: Create partname and partid debug files for child MTDs Petr Malat
@ 2021-04-30  7:02 ` Michael Walle
  2021-05-06 14:57   ` Petr Malat
  2021-05-10 10:43 ` Miquel Raynal
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Walle @ 2021-04-30  7:02 UTC (permalink / raw)
  To: Petr Malat
  Cc: linux-mtd, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

Hi Petr,

Am 2021-04-30 08:50, schrieb Petr Malat:
> Partname and partid are set by the upper driver (spi-nor) on the master
> MTD. If this MTD is partitioned and CONFIG_MTD_PARTITIONED_MASTER is
> disabled, the master MTD is not instantiated and partname and partid
> aren't available to the userspace.

You might have a look at:
https://lore.kernel.org/linux-mtd/20210429155713.28808-1-michael@walle.cc/

This is just for spi-nor though, but attaches the properties to the
flash device instead of the mtd device.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: Create partname and partid debug files for child MTDs
  2021-04-30  7:02 ` Michael Walle
@ 2021-05-06 14:57   ` Petr Malat
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Malat @ 2021-05-06 14:57 UTC (permalink / raw)
  To: Michael Walle
  Cc: linux-mtd, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

Hi!
On Fri, Apr 30, 2021 at 09:02:14AM +0200, Michael Walle wrote:
> > Partname and partid are set by the upper driver (spi-nor) on the master
> > MTD. If this MTD is partitioned and CONFIG_MTD_PARTITIONED_MASTER is
> > disabled, the master MTD is not instantiated and partname and partid
> > aren't available to the userspace.
> 
> You might have a look at:
> https://lore.kernel.org/linux-mtd/20210429155713.28808-1-michael@walle.cc/
Thanks, I used it to replace my hack to dump SFDP with print_hex_dump.
As it seems I'm not the only one interested in SFDP in userspace I
have pushed my SFDP parser to github https://github.com/petris/sfdp-parser

> This is just for spi-nor though, but attaches the properties to the
> flash device instead of the mtd device.
Currently, no other driver is using it. If your change makes it in,
debugfs attributes can be removed (or extended to cover other drivers
as well).
  Petr

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: Create partname and partid debug files for child MTDs
  2021-04-30  6:50 [PATCH] mtd: Create partname and partid debug files for child MTDs Petr Malat
  2021-04-30  7:02 ` Michael Walle
@ 2021-05-10 10:43 ` Miquel Raynal
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2021-05-10 10:43 UTC (permalink / raw)
  To: Petr Malat, linux-mtd
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

On Fri, 2021-04-30 at 06:50:57 UTC, Petr Malat wrote:
> Partname and partid are set by the upper driver (spi-nor) on the master
> MTD. If this MTD is partitioned and CONFIG_MTD_PARTITIONED_MASTER is
> disabled, the master MTD is not instantiated and partname and partid
> aren't available to the userspace.
> 
> Always read the partname and partid from the master MTD, they describe
> the HW, which can't differ between master and its children.
> 
> Signed-off-by: Petr Malat <oss@malat.biz>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-10 10:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30  6:50 [PATCH] mtd: Create partname and partid debug files for child MTDs Petr Malat
2021-04-30  7:02 ` Michael Walle
2021-05-06 14:57   ` Petr Malat
2021-05-10 10:43 ` Miquel Raynal

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).