linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] mtd: add | as a separator after mtd-id
@ 2020-03-20 20:21 ron minnich
  2020-03-21 15:44 ` ron minnich
  0 siblings, 1 reply; 5+ messages in thread
From: ron minnich @ 2020-03-20 20:21 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd

The MTD subsystem can support command-line defined partitions
for one or more MTD devices.

The format is:
 * mtdparts=<mtddef>[;<mtddef]
 * <mtddef>  := <mtd-id>:<partdef>[,<partdef>]

The ':' currently separates the id from the partdef.

The mtdparts can define more than one part, in which case
there will be more than one <mtd-id>:<partdef> component.

The problem comes in with newer systems which have MTDs
attached to a PCI device, which has a PCI name including
several :'s, e.g. 0000:00:1f.5 on an Intel chipset. Although
this is largely an x86 problem at the moment, PCI is coming
to newer ARM systems, and they will hit this issue in future.

There are two : in the name alone. strchr is used to find
the <mtd-id>, and in this case it will return the wrong
result. Using strrchr is not an option, as there may
be more than one mtddef in the argument.

This patch defines a new delimiter, |, to seperate
the <mtd-id> from the <partdef>. | is rarely used
in device names, so seems a reasonable choice.

The code first searches for | and, if that fails, searches
for the old :. Eventually, it ought to be possible to remove
the support for : entirely, but since mtdparts are also defined
in FLASH in the device tree on many ARM boards, wholesale removal
is not yet practical.

This code has been used on real hardware and allowed us to use a
squashfs in SPI-NOR flash as a root file system, with partitions
defined on the cmdline.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
Change-Id: Ifce3627cb03247bf9e54c8b19d24b60baeed2ec3
---
 drivers/mtd/parsers/cmdlinepart.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/parsers/cmdlinepart.c
b/drivers/mtd/parsers/cmdlinepart.c
index c86f2db8c882..eca8ec026d89 100644
--- a/drivers/mtd/parsers/cmdlinepart.c
+++ b/drivers/mtd/parsers/cmdlinepart.c
@@ -223,7 +223,14 @@ static int mtdpart_setup_real(char *s)
         mtd_id = s;

         /* fetch <mtd-id> */
-        p = strchr(s, ':');
+        p = strchr(s, '|');
+        if (!p) {
+            /*
+             * ':' is the older separator, which conflicts
+             * with PCI IDs T:B:D.F; too many  :'s!
+             */
+            p = strchr(s, ':');
+        }
         if (!p) {
             pr_err("no mtd-id\n");
             return -EINVAL;
-- 
2.25.1.696.g5e7596f4ac-goog

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

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

end of thread, other threads:[~2020-03-22 16:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 20:21 [PATCH 1/1] mtd: add | as a separator after mtd-id ron minnich
2020-03-21 15:44 ` ron minnich
2020-03-22 11:09   ` Miquel Raynal
2020-03-22 15:42     ` ron minnich
2020-03-22 16:00       ` ron minnich

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