aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/fsmc_nand.c
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2011-06-02 10:00:38 -0400
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-09-11 08:02:08 -0400
commit0d04eda1430e9a796214bee644b7e05d99cfe613 (patch)
treebb4b26314b9ce976bc81937e1f980655f9464014 /drivers/mtd/nand/fsmc_nand.c
parent6cb03c9cb520186859a034e4e829fb591aea78b6 (diff)
mtd: fsmc_nand.c: use mtd_device_parse_register
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. Linus Walleij: fixed compilation breakage Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/nand/fsmc_nand.c')
-rw-r--r--drivers/mtd/nand/fsmc_nand.c66
1 files changed, 9 insertions, 57 deletions
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index a39c224eb12f..e53b76064133 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[] = {
146 { 146 {
147 .name = "Root File System", 147 .name = "Root File System",
148 .offset = 0x460000, 148 .offset = 0x460000,
149 .size = 0, 149 .size = MTDPART_SIZ_FULL,
150 }, 150 },
151}; 151};
152 152
@@ -173,7 +173,7 @@ static struct mtd_partition partition_info_128KB_blk[] = {
173 { 173 {
174 .name = "Root File System", 174 .name = "Root File System",
175 .offset = 0x800000, 175 .offset = 0x800000,
176 .size = 0, 176 .size = MTDPART_SIZ_FULL,
177 }, 177 },
178}; 178};
179 179
@@ -184,8 +184,6 @@ static struct mtd_partition partition_info_128KB_blk[] = {
184 * @pid: Part ID on the AMBA PrimeCell format 184 * @pid: Part ID on the AMBA PrimeCell format
185 * @mtd: MTD info for a NAND flash. 185 * @mtd: MTD info for a NAND flash.
186 * @nand: Chip related info for a NAND flash. 186 * @nand: Chip related info for a NAND flash.
187 * @partitions: Partition info for a NAND Flash.
188 * @nr_partitions: Total number of partition of a NAND flash.
189 * 187 *
190 * @ecc_place: ECC placing locations in oobfree type format. 188 * @ecc_place: ECC placing locations in oobfree type format.
191 * @bank: Bank number for probed device. 189 * @bank: Bank number for probed device.
@@ -200,8 +198,6 @@ struct fsmc_nand_data {
200 u32 pid; 198 u32 pid;
201 struct mtd_info mtd; 199 struct mtd_info mtd;
202 struct nand_chip nand; 200 struct nand_chip nand;
203 struct mtd_partition *partitions;
204 unsigned int nr_partitions;
205 201
206 struct fsmc_eccplace *ecc_place; 202 struct fsmc_eccplace *ecc_place;
207 unsigned int bank; 203 unsigned int bank;
@@ -717,57 +713,13 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
717 * Check for partition info passed 713 * Check for partition info passed
718 */ 714 */
719 host->mtd.name = "nand"; 715 host->mtd.name = "nand";
720 host->nr_partitions = parse_mtd_partitions(&host->mtd, NULL, 716 ret = mtd_device_parse_register(&host->mtd, NULL, 0,
721 &host->partitions, 0); 717 host->mtd.size <= 0x04000000 ?
722 if (host->nr_partitions <= 0) { 718 partition_info_16KB_blk :
723 /* 719 partition_info_128KB_blk,
724 * Check if partition info passed via command line 720 host->mtd.size <= 0x04000000 ?
725 */ 721 ARRAY_SIZE(partition_info_16KB_blk) :
726 if (pdata->partitions) { 722 ARRAY_SIZE(partition_info_128KB_blk));
727 host->partitions = pdata->partitions;
728 host->nr_partitions = pdata->nr_partitions;
729 } else {
730 struct mtd_partition *partition;
731 int i;
732
733 /* Select the default partitions info */
734 switch (host->mtd.size) {
735 case 0x01000000:
736 case 0x02000000:
737 case 0x04000000:
738 host->partitions = partition_info_16KB_blk;
739 host->nr_partitions =
740 sizeof(partition_info_16KB_blk) /
741 sizeof(struct mtd_partition);
742 break;
743 case 0x08000000:
744 case 0x10000000:
745 case 0x20000000:
746 case 0x40000000:
747 host->partitions = partition_info_128KB_blk;
748 host->nr_partitions =
749 sizeof(partition_info_128KB_blk) /
750 sizeof(struct mtd_partition);
751 break;
752 default:
753 ret = -ENXIO;
754 pr_err("Unsupported NAND size\n");
755 goto err_probe;
756 }
757
758 partition = host->partitions;
759 for (i = 0; i < host->nr_partitions; i++, partition++) {
760 if (partition->size == 0) {
761 partition->size = host->mtd.size -
762 partition->offset;
763 break;
764 }
765 }
766 }
767 }
768
769 ret = mtd_device_register(&host->mtd, host->partitions,
770 host->nr_partitions);
771 if (ret) 723 if (ret)
772 goto err_probe; 724 goto err_probe;
773 725