public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Dmitry Baryshkov <dbaryshkov@gmail.com>,
	Eric Miao <eric.miao@marvell.com>
Subject: [PATCH 4/6] [MTD] sharpsl-nand: cleanup partitions support
Date: Fri, 17 Oct 2008 03:15:07 +0400	[thread overview]
Message-ID: <1224198909-17568-4-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1224198909-17568-3-git-send-email-dbaryshkov@gmail.com>

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/sharpsl.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 328e02e..17625c0 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -2,6 +2,7 @@
  * drivers/mtd/nand/sharpsl.c
  *
  *  Copyright (C) 2004 Richard Purdie
+ *  Copyright (C) 2008 Dmitry Baryshkov
  *
  *  Based on Sharp's NAND driver sharp_sl.c
  *
@@ -52,12 +53,12 @@ struct sharpsl_nand {
 #define FLCLE		(1 << 1)
 #define FLCE0		(1 << 0)
 
+#ifdef CONFIG_MTD_PARTITIONS
 /*
  * Define partitions for flash device
  */
 #define DEFAULT_NUM_PARTITIONS 3
 
-static int nr_partitions;
 static struct mtd_partition sharpsl_nand_default_partition_info[] = {
 	{
 	 .name = "System Area",
@@ -75,6 +76,7 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = {
 	 .size = MTDPART_SIZ_FULL,
 	 },
 };
+#endif
 
 /*
  *	hardware specific access to control-lines
@@ -151,7 +153,7 @@ static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat,
 }
 
 #ifdef CONFIG_MTD_PARTITIONS
-const char *part_probes[] = { "cmdlinepart", NULL };
+static const char *part_probes[] = { "cmdlinepart", NULL };
 #endif
 
 /*
@@ -160,7 +162,10 @@ const char *part_probes[] = { "cmdlinepart", NULL };
 static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
 {
 	struct nand_chip *this;
+#ifdef CONFIG_MTD_PARTITIONS
 	struct mtd_partition *sharpsl_partition_info;
+	int nr_partitions;
+#endif
 	struct resource *r;
 	int err = 0;
 	struct sharpsl_nand *sharpsl;
@@ -229,10 +234,11 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
 
 	/* Register the partitions */
 	sharpsl->mtd.name = "sharpsl-nand";
+#ifdef CONFIG_MTD_PARTITIONS
 	nr_partitions = parse_mtd_partitions(&sharpsl->mtd, part_probes, &sharpsl_partition_info, 0);
 
 	if (nr_partitions <= 0) {
-		nr_partitions = DEFAULT_NUM_PARTITIONS;
+		nr_partitions = ARRAY_SIZE(sharpsl_nand_default_partition_info);
 		sharpsl_partition_info = sharpsl_nand_default_partition_info;
 		if (machine_is_poodle()) {
 			sharpsl_partition_info[1].size = 22 * 1024 * 1024;
@@ -249,11 +255,19 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
 		}
 	}
 
-	add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions);
+	err = add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions);
+#else
+	err = add_mtd_device(&sharpsl->mtd);
+#endif
+	if (err)
+		goto err_add;
 
 	/* Return happy */
 	return 0;
 
+err_add:
+	nand_release(&sharpsl->mtd);
+
 err_scan:
 	platform_set_drvdata(pdev, NULL);
 	iounmap(sharpsl->io);
-- 
1.5.6.5

  reply	other threads:[~2008-10-16 23:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-16 23:11 [GIT PULL] sharpsl-nand driver model hookup Dmitry Baryshkov
2008-10-16 23:13 ` Dmitry Baryshkov
2008-10-16 23:15 ` [PATCH 1/6] [MTD] sharpsl_nand: switch to driver model usage Dmitry Baryshkov
2008-10-16 23:15   ` [PATCH 2/6] [MTD] sharpsl_nand: make drvdata non-static Dmitry Baryshkov
2008-10-16 23:15     ` [PATCH 3/6] [MTD] sharpsl_nand: move io addr to struct sharpsl_nand Dmitry Baryshkov
2008-10-16 23:15       ` Dmitry Baryshkov [this message]
2008-10-16 23:15         ` [PATCH 5/6] [MTD] sharpsl-nand: use platform_data for model-specific values Dmitry Baryshkov
2008-10-16 23:15           ` [PATCH 6/6] [MTD] sharpsl-nand: move registration to board code Dmitry Baryshkov
2008-11-25  9:05 ` [GIT PULL] sharpsl-nand driver model hookup Eric Miao
2008-12-01  2:13   ` Dmitry
2008-12-10 15:59     ` David Woodhouse
2008-12-11  1:08       ` Dmitry Eremin-Solenikov

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=1224198909-17568-4-git-send-email-dbaryshkov@gmail.com \
    --to=dbaryshkov@gmail.com \
    --cc=eric.miao@marvell.com \
    --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