提交 eb13fa02 编写于 作者: B Boris Brezillon 提交者: Richard Weinberger

mtd: parser: cmdline: Support MTD names containing one or more colons

Looks like some drivers define MTD names with a colon in it, thus
making mtdpart= parsing impossible. Let's fix the parser to gracefully
handle that case: the last ':' in a partition definition sequence is
considered instead of the first one.
Signed-off-by: NBoris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: NRon Minnich <rminnich@google.com>
Tested-by: NRon Minnich <rminnich@google.com>
Signed-off-by: NRichard Weinberger <richard@nod.at>
上级 9029537c
...@@ -226,12 +226,29 @@ static int mtdpart_setup_real(char *s) ...@@ -226,12 +226,29 @@ static int mtdpart_setup_real(char *s)
struct cmdline_mtd_partition *this_mtd; struct cmdline_mtd_partition *this_mtd;
struct mtd_partition *parts; struct mtd_partition *parts;
int mtd_id_len, num_parts; int mtd_id_len, num_parts;
char *p, *mtd_id; char *p, *mtd_id, *semicol;
/*
* Replace the first ';' by a NULL char so strrchr can work
* properly.
*/
semicol = strchr(s, ';');
if (semicol)
*semicol = '\0';
mtd_id = s; mtd_id = s;
/* fetch <mtd-id> */ /*
p = strchr(s, ':'); * fetch <mtd-id>. We use strrchr to ignore all ':' that could
* be present in the MTD name, only the last one is interpreted
* as an <mtd-id>/<part-definition> separator.
*/
p = strrchr(s, ':');
/* Restore the ';' now. */
if (semicol)
*semicol = ';';
if (!p) { if (!p) {
pr_err("no mtd-id\n"); pr_err("no mtd-id\n");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册