From patchwork Mon Feb 16 16:21:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 23222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3356BDDDF3 for ; Tue, 17 Feb 2009 03:11:41 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LZ62C-0005mX-7M; Mon, 16 Feb 2009 16:09:28 +0000 Received: from smtp.nokia.com ([192.100.122.233] helo=mgw-mx06.nokia.com) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1LZ626-0005mP-T9; Mon, 16 Feb 2009 16:09:25 +0000 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx06.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n1GG9DcE016040; Mon, 16 Feb 2009 18:09:18 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 16 Feb 2009 18:07:30 +0200 Received: from vaebe112.NOE.Nokia.com ([10.160.244.81]) by esebh102.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 16 Feb 2009 18:07:29 +0200 Received: from [172.21.41.224] ([172.21.41.224]) by vaebe112.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 16 Feb 2009 18:07:29 +0200 Message-ID: <4999928F.1010304@nokia.com> Date: Mon, 16 Feb 2009 18:21:35 +0200 From: Adrian Hunter User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: David Woodhouse Subject: [PATCH] mtdoops: allow MTD selection by name X-OriginalArrivalTime: 16 Feb 2009 16:07:29.0735 (UTC) FILETIME=[AAFE5D70:01C99050] X-Nokia-AV: Clean X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.100.122.233 listed in list.dnswl.org] Cc: linux-mtd Mailing List , Viktor Rosendahl X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Acked-by: Artem Bityutskiy Acked-by: Richard Purdie --- 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 1a6b3be..fdf504f 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -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) return; @@ -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) unregister_mtd_user(&mtdoops_notifier); unregister_console(&mtdoops_console); + kfree(cxt->name); vfree(cxt->oops_buf); }