Commit e2a0f25b authored by Adrian Hunter's avatar Adrian Hunter Committed by David Woodhouse

[MTD] mtdoops: allow MTD selection by name

MTD's have both an index number and a name.  Formerly,
the MTD selected for mtdoops was done only by index
number.  With this patch, a name can be used instead.

For example, the kernel command line:


selects MTD 5 for mtdoops.  But now this is also possible:


which selects the MTD named "log" for mtdoops.

This has the advantage that partitions can be added or
removed that would affect the MTD index number but not the
name, without having to then change the kernel command line.
Signed-off-by: default avatarAdrian Hunter <>
Acked-by: default avatarRichard Purdie <>
Acked-by: default avatarArtem Bityutskiy <>
Signed-off-by: default avatarDavid Woodhouse <>
parent f271049e
......@@ -44,6 +44,7 @@ static struct mtdoops_context {
int oops_pages;
int nextpage;
int nextcount;
char *name;
void *oops_buf;
......@@ -273,6 +274,9 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
struct mtdoops_context *cxt = &oops_cxt;
if (cxt->name && !strcmp(mtd->name, cxt->name))
cxt->mtd_index = mtd->index;
if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0)
......@@ -383,8 +387,12 @@ static int __init mtdoops_console_setup(struct console *co, char *options)
struct mtdoops_context *cxt = co->data;
if (cxt->mtd_index != -1)
if (cxt->mtd_index != -1 || cxt->name)
return -EBUSY;
if (options) {
cxt->name = kstrdup(options, GFP_KERNEL);
return 0;
if (co->index == -1)
return -EINVAL;
......@@ -432,6 +440,7 @@ static void __exit mtdoops_console_exit(void)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment