From patchwork Tue Jan 10 14:29:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 135249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5996BB6FA5 for ; Wed, 11 Jan 2012 01:41:56 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RkcsW-00045O-LI; Tue, 10 Jan 2012 14:40:44 +0000 Received: from mo-p05-ob6.rzone.de ([2a01:238:20a:202:53f5::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RkcsT-00044W-4p for linux-mtd@lists.infradead.org; Tue, 10 Jan 2012 14:40:41 +0000 X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGoheedClaTaNdBkW0QEactrHijJzVWE2h/r1F6X X-RZG-CLASS-ID: mo05 Received: from kubuntu.fritz.box (pD9FFA2EA.dip.t-dialin.net [217.255.162.234]) by smtp.strato.de (jimi mo38) (RZmta 27.3 DYNA|AUTH) with ESMTPA id j038bbo0ACuKXs ; Tue, 10 Jan 2012 15:29:16 +0100 (MET) From: Stefan Roese To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: fsmc_nand.c: Partition info from pdata overrides driver defaults Date: Tue, 10 Jan 2012 15:29:08 +0100 Message-Id: <1326205748-9867-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.7.8.3 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: dedekind@infradead.org, Dmitry Eremin-Solenikov X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 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 This patch enables the partition info from the platform data (if provided) to override the default partition info included in the fsmc NAND driver. Signed-off-by: Stefan Roese Cc: Dmitry Eremin-Solenikov --- drivers/mtd/nand/fsmc_nand.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index e53b760..d48dc79 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -533,6 +533,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) struct nand_chip *nand; struct fsmc_regs *regs; struct resource *res; + struct mtd_partition *parts; + int count; int ret = 0; u32 pid; int i; @@ -713,13 +715,19 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) * Check for partition info passed */ host->mtd.name = "nand"; - 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 (pdata->partitions) { + parts = pdata->partitions; + count = pdata->nr_partitions; + } else { + if (host->mtd.size <= 0x04000000) { + parts = partition_info_16KB_blk; + count = ARRAY_SIZE(partition_info_16KB_blk); + } else { + parts = partition_info_128KB_blk; + count = ARRAY_SIZE(partition_info_128KB_blk); + } + } + ret = mtd_device_parse_register(&host->mtd, NULL, 0, parts, count); if (ret) goto err_probe;