public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>, dedekind1@gmail.com
Subject: [PATCH 29/44] mtd: fsmc_nand.c: use mtd_device_parse_register
Date: Tue,  7 Jun 2011 17:36:28 +0400	[thread overview]
Message-ID: <1307453803-31950-30-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1307453803-31950-1-git-send-email-dbaryshkov@gmail.com>

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 <dbaryshkov@gmail.com>
---
 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;
 
-- 
1.7.4.4

  parent reply	other threads:[~2011-06-07 13:37 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 13:35 [PATCH 00/44] Cleanup of parse/register scenario Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 01/44] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
2011-06-07 13:44   ` Jamie Iles
2011-06-07 14:33     ` Dmitry Eremin-Solenikov
2011-06-08  8:37       ` Artem Bityutskiy
2011-06-08  8:57         ` Dmitry Eremin-Solenikov
2011-06-08  8:57           ` Artem Bityutskiy
2011-06-07 15:48     ` Dmitry Eremin-Solenikov
2011-06-08  8:55       ` Artem Bityutskiy
2011-06-08 10:19       ` Jamie Iles
2011-06-08 12:22         ` Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 02/44] mtd: lart.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
2011-06-08  8:59   ` Artem Bityutskiy
2011-06-07 13:36 ` [PATCH 03/44] mtd: mtd_dataflash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 04/44] mtd: sst25l.c: " Dmitry Eremin-Solenikov
2011-06-08  9:00   ` Artem Bityutskiy
2011-06-07 13:36 ` [PATCH 05/44] mtd: bfin-async-flash.c: " Dmitry Eremin-Solenikov
2011-06-08  9:01   ` Artem Bityutskiy
2011-06-08  9:02     ` Artem Bityutskiy
2011-06-08 14:06       ` Dmitry Eremin-Solenikov
2011-06-08 14:12         ` Artem Bityutskiy
2011-06-08 14:22           ` Dmitry Eremin-Solenikov
2011-06-08 14:24             ` Artem Bityutskiy
2011-06-08 14:31               ` Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 06/44] mtd: dc21285.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 07/44] mtd: gpio-addr-flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 08/44] mtd: h720x-flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 09/44] mtd: impa7.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 10/44] mtd: intel_vr_nor.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 11/44] mtd: ixp2000.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 12/44] mtd: ixp4xx.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 13/44] mtd: lantiq-flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 14/44] mtd: latch-addr-flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 15/44] mtd: physmap.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 16/44] mtd: plat-ram.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 17/44] mtd: pxa2xx-flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 18/44] mtd: rbtx4939-flash.c: " Dmitry Eremin-Solenikov
2011-06-08 13:50   ` Atsushi Nemoto
2011-06-08 14:07     ` Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 19/44] mtd: sa1100-flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 20/44] mtd: solutionengine.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 21/44] mtd: wr_sbc82xx_flash.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 22/44] mtd: atmel_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 23/44] mtd: bcm_umi_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 24/44] mtd: cafe_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 25/44] mtd: cmx270_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 26/44] mtd: cs553x_nand.c: " Dmitry Eremin-Solenikov
2011-06-08  9:19   ` Artem Bityutskiy
2011-06-08 14:05     ` Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 27/44] mtd: davinci_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 28/44] mtd: edb7312.c: " Dmitry Eremin-Solenikov
2011-06-08  9:20   ` Artem Bityutskiy
2011-06-08 14:04     ` Dmitry Eremin-Solenikov
2011-06-07 13:36 ` Dmitry Eremin-Solenikov [this message]
2011-06-07 13:36 ` [PATCH 30/44] mtd: h1910.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 31/44] mtd: jz4740_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 32/44] mtd: mxc_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 33/44] mtd: omap2.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 34/44] mtd: orion_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 35/44] mtd: plat_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 36/44] mtd: ppchameleonevb.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 37/44] mtd: pxa3xx_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 38/44] mtd: s3c2410.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 39/44] mtd: sharpsl.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 40/44] mtd: tmio_nand.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 41/44] mtd: txx9ndfmc.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 42/44] mtd: onenand/generic.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 43/44] mtd: onenand/omap2.c: " Dmitry Eremin-Solenikov
2011-06-07 13:36 ` [PATCH 44/44] mtd: onenand/samsung.c: " Dmitry Eremin-Solenikov
2011-06-08  9:26 ` [PATCH 00/44] Cleanup of parse/register scenario Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307453803-31950-30-git-send-email-dbaryshkov@gmail.com \
    --to=dbaryshkov@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox