From patchwork Tue Jan 10 14:29:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: mtd: fsmc_nand.c: Partition info from pdata overrides driver defaults Date: Tue, 10 Jan 2012 04:29:08 -0000 From: Stefan Roese X-Patchwork-Id: 135249 Message-Id: <1326205748-9867-1-git-send-email-sr@denx.de> To: linux-mtd@lists.infradead.org Cc: dedekind@infradead.org, Dmitry Eremin-Solenikov 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;