Patchwork mtd: fsmc_nand.c: Partition info from pdata overrides driver defaults

login
register
mail settings
Submitter Stefan Roese
Date Jan. 10, 2012, 2:29 p.m.
Message ID <1326205748-9867-1-git-send-email-sr@denx.de>
Download mbox | patch
Permalink /patch/135249/
State New
Headers show

Comments

Stefan Roese - Jan. 10, 2012, 2:29 p.m.
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 <sr@denx.de>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsmc_nand.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

Patch

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;