From patchwork Wed Jun 8 16:05:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 99489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8C1B9B6FBA for ; Thu, 9 Jun 2011 02:16:37 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QULL5-0004GB-ST; Wed, 08 Jun 2011 16:10:41 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QULL2-0008H5-7T; Wed, 08 Jun 2011 16:10:36 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QULHH-0007CU-HR for linux-mtd@lists.infradead.org; Wed, 08 Jun 2011 16:06:45 +0000 Received: by mail-wy0-f177.google.com with SMTP id 28so630582wyb.36 for ; Wed, 08 Jun 2011 09:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=KeRn1V0kXm8cyCKWN7+eEAjv3OwaOea59b0HhuIyL+I=; b=FE5Qje7s6/0TqC1CVDt3OaALlhNHenyJH9dZSAtzvmh9UqSB/McxaZBHXPzwo4xHt3 qW9QGOVe38XN4kqzyViaMv8xuFUxzTKxSiULa/7fkv4JsDST6MtKqGnt/4D0U9bVDXpk aJk1dOR/6zpVk3ul5n0xI+NNUm3NoQISnaDbo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=OICWYvf0sYBExOo2OHPxxkQdfSbp/1Qqp8XAFVrKCnah7Y0aAGff0lMgZqVSnEQPmX hy2jZ9gCmrIXN9SgvDm1dcldqxwDpHALjmlVc8Ue5f6ilopPUOXh/aIpH3ojoBsL669n H9yQ/gchbVVQMBDxUGYyD90JHRgbHgupNtRBY= Received: by 10.227.206.21 with SMTP id fs21mr7891915wbb.40.1307549202876; Wed, 08 Jun 2011 09:06:42 -0700 (PDT) Received: from doriath.ww600.siemens.net ([91.213.169.4]) by mx.google.com with ESMTPS id p21sm526733wbh.6.2011.06.08.09.06.41 (version=SSLv3 cipher=OTHER); Wed, 08 Jun 2011 09:06:42 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-mtd@lists.infradead.org Subject: [PATCH 28/43] mtd: fsmc_nand.c: use mtd_device_parse_register Date: Wed, 8 Jun 2011 20:05:37 +0400 Message-Id: <1307549152-7085-29-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1307549152-7085-1-git-send-email-dbaryshkov@gmail.com> References: <1307549152-7085-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110608_120643_944877_3D3EAA33 X-CRM114-Status: GOOD ( 17.92 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (dbaryshkov[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: David Woodhouse , Russell King , dedekind1@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Replace custom invocations of parse_mtd_partitions and mtd_device_register with common mtd_device_parse_register call. This would bring: standard handling of all errors, fallback to default partitions, etc. Signed-off-by: Dmitry Eremin-Solenikov --- drivers/mtd/nand/fsmc_nand.c | 66 ++++++------------------------------------ 1 files changed, 9 insertions(+), 57 deletions(-) diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index a39c224..8cc8065 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -146,7 +146,7 @@ static struct mtd_partition partition_info_16KB_blk[] = { { .name = "Root File System", .offset = 0x460000, - .size = 0, + .size = MTDPART_SIZ_FULL, }, }; @@ -173,7 +173,7 @@ static struct mtd_partition partition_info_128KB_blk[] = { { .name = "Root File System", .offset = 0x800000, - .size = 0, + .size = MTDPART_SIZ_FULL, }, }; @@ -184,8 +184,6 @@ static struct mtd_partition partition_info_128KB_blk[] = { * @pid: Part ID on the AMBA PrimeCell format * @mtd: MTD info for a NAND flash. * @nand: Chip related info for a NAND flash. - * @partitions: Partition info for a NAND Flash. - * @nr_partitions: Total number of partition of a NAND flash. * * @ecc_place: ECC placing locations in oobfree type format. * @bank: Bank number for probed device. @@ -200,8 +198,6 @@ struct fsmc_nand_data { u32 pid; struct mtd_info mtd; struct nand_chip nand; - struct mtd_partition *partitions; - unsigned int nr_partitions; struct fsmc_eccplace *ecc_place; unsigned int bank; @@ -717,57 +713,13 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) * Check for partition info passed */ host->mtd.name = "nand"; - host->nr_partitions = parse_mtd_partitions(&host->mtd, NULL, - &host->partitions, 0); - if (host->nr_partitions <= 0) { - /* - * Check if partition info passed via command line - */ - if (pdata->partitions) { - host->partitions = pdata->partitions; - host->nr_partitions = pdata->nr_partitions; - } else { - struct mtd_partition *partition; - int i; - - /* Select the default partitions info */ - switch (host->mtd.size) { - case 0x01000000: - case 0x02000000: - case 0x04000000: - host->partitions = partition_info_16KB_blk; - host->nr_partitions = - sizeof(partition_info_16KB_blk) / - sizeof(struct mtd_partition); - break; - case 0x08000000: - case 0x10000000: - case 0x20000000: - case 0x40000000: - host->partitions = partition_info_128KB_blk; - host->nr_partitions = - sizeof(partition_info_128KB_blk) / - sizeof(struct mtd_partition); - break; - default: - ret = -ENXIO; - pr_err("Unsupported NAND size\n"); - goto err_probe; - } - - partition = host->partitions; - for (i = 0; i < host->nr_partitions; i++, partition++) { - if (partition->size == 0) { - partition->size = host->mtd.size - - partition->offset; - break; - } - } - } - } - - ret = mtd_device_register(&host->mtd, host->partitions, - host->nr_partitions); + ret = mtd_device_parse_register(&host->mtd, NULL, 0, + host->mtd.size <= 0x04000000 ? + partition_info_16KB_blk : + partition_info_128KB_blk, + host->mtd.size <= 0x04000000 ? + ARRAY_SIZE(partition_info_16KB_blk) : + ARRAY_SIZE(partition_info_128KB_blk), if (ret) goto err_probe;