diff options
author | Adrian Hunter <ext-adrian.hunter@nokia.com> | 2009-02-16 11:21:35 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-03-20 14:38:58 -0400 |
commit | e2a0f25b4f520adbd82c0caafcde0470ed11053d (patch) | |
tree | caac8295d3afbab87b593748c67344737c49c554 /drivers | |
parent | f271049e2010b918f83dc1c7bbd5d75f4710506a (diff) |
[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:
console=ttyMTD5
selects MTD 5 for mtdoops. But now this is also possible:
console=ttyMTD,log
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: Adrian Hunter <ext-adrian.hunter@nokia.com>
Acked-by: Richard Purdie <rpurdie@linux.intel.com>
Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/mtdoops.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 1a6b3beabe8d..fdf504fb319a 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
@@ -44,6 +44,7 @@ static struct mtdoops_context { | |||
44 | int oops_pages; | 44 | int oops_pages; |
45 | int nextpage; | 45 | int nextpage; |
46 | int nextcount; | 46 | int nextcount; |
47 | char *name; | ||
47 | 48 | ||
48 | void *oops_buf; | 49 | void *oops_buf; |
49 | 50 | ||
@@ -273,6 +274,9 @@ static void mtdoops_notify_add(struct mtd_info *mtd) | |||
273 | { | 274 | { |
274 | struct mtdoops_context *cxt = &oops_cxt; | 275 | struct mtdoops_context *cxt = &oops_cxt; |
275 | 276 | ||
277 | if (cxt->name && !strcmp(mtd->name, cxt->name)) | ||
278 | cxt->mtd_index = mtd->index; | ||
279 | |||
276 | if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0) | 280 | if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0) |
277 | return; | 281 | return; |
278 | 282 | ||
@@ -383,8 +387,12 @@ static int __init mtdoops_console_setup(struct console *co, char *options) | |||
383 | { | 387 | { |
384 | struct mtdoops_context *cxt = co->data; | 388 | struct mtdoops_context *cxt = co->data; |
385 | 389 | ||
386 | if (cxt->mtd_index != -1) | 390 | if (cxt->mtd_index != -1 || cxt->name) |
387 | return -EBUSY; | 391 | return -EBUSY; |
392 | if (options) { | ||
393 | cxt->name = kstrdup(options, GFP_KERNEL); | ||
394 | return 0; | ||
395 | } | ||
388 | if (co->index == -1) | 396 | if (co->index == -1) |
389 | return -EINVAL; | 397 | return -EINVAL; |
390 | 398 | ||
@@ -432,6 +440,7 @@ static void __exit mtdoops_console_exit(void) | |||
432 | 440 | ||
433 | unregister_mtd_user(&mtdoops_notifier); | 441 | unregister_mtd_user(&mtdoops_notifier); |
434 | unregister_console(&mtdoops_console); | 442 | unregister_console(&mtdoops_console); |
443 | kfree(cxt->name); | ||
435 | vfree(cxt->oops_buf); | 444 | vfree(cxt->oops_buf); |
436 | } | 445 | } |
437 | 446 | ||