Patchwork [1/7] mtd: OneNAND: OMAP2/3: add support for command line partitioning

login
register
mail settings
Submitter Adrian Hunter
Date Dec. 13, 2010, 12:20 p.m.
Message ID <20101213122051.20685.46383.sendpatchset@ahunter-work.research.nokia.com>
Download mbox | patch
Permalink /patch/75321/
State New
Headers show

Comments

Adrian Hunter - Dec. 13, 2010, 12:20 p.m.
From d27a88c5f9f18a7c38784c085889c3e1053340cf Mon Sep 17 00:00:00 2001
From: Adrian Hunter <adrian.hunter@nokia.com>
Date: Wed, 30 Dec 2009 07:40:16 +0100
Subject: [PATCH 1/7] mtd: OneNAND: OMAP2/3: add support for command line partitioning

Add the ability to parse MTD partition information from the
kernel command line.

Note that a pointless BUG_ON is removed, as are redundant
calls to 'del_mtd_partitions()' and 'del_mtd_device()'
because they are also done by 'onenand_release()'.

Finally note that 'add_mtd_device()' returns 1 on failure
so the error condition was incorrect.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
---
 drivers/mtd/onenand/omap2.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)
Artem Bityutskiy - Dec. 15, 2010, 2:04 p.m.
On Mon, 2010-12-13 at 14:20 +0200, Adrian Hunter wrote:
> From d27a88c5f9f18a7c38784c085889c3e1053340cf Mon Sep 17 00:00:00 2001
> From: Adrian Hunter <adrian.hunter@nokia.com>
> Date: Wed, 30 Dec 2009 07:40:16 +0100
> Subject: [PATCH 1/7] mtd: OneNAND: OMAP2/3: add support for command line partitioning
> 
> Add the ability to parse MTD partition information from the
> kernel command line.
> 
> Note that a pointless BUG_ON is removed, as are redundant
> calls to 'del_mtd_partitions()' and 'del_mtd_device()'
> because they are also done by 'onenand_release()'.
> 
> Finally note that 'add_mtd_device()' returns 1 on failure
> so the error condition was incorrect.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>

I've pushed patches 1 and 7 to l2-mtd-2.6, but patch #2 is not
applicable. I think this is because of changes Kyungmin made recently.
Could you please re-send patches 2 and 3 on top of the l2 tree?

I guess I can apply 2 and 3 now. Patch 4 should wait for comments from
Tony, AFAICS. Patches 5 and 6 are dependent, and hence should wait as
well, AFAICS.
Artem Bityutskiy - Dec. 15, 2010, 2:06 p.m.
On Mon, 2010-12-13 at 14:20 +0200, Adrian Hunter wrote:
> From d27a88c5f9f18a7c38784c085889c3e1053340cf Mon Sep 17 00:00:00 2001
> From: Adrian Hunter <adrian.hunter@nokia.com>
> Date: Wed, 30 Dec 2009 07:40:16 +0100
> Subject: [PATCH 1/7] mtd: OneNAND: OMAP2/3: add support for command line partitioning
> 
> Add the ability to parse MTD partition information from the
> kernel command line.
> 
> Note that a pointless BUG_ON is removed, as are redundant
> calls to 'del_mtd_partitions()' and 'del_mtd_device()'
> because they are also done by 'onenand_release()'.
> 
> Finally note that 'add_mtd_device()' returns 1 on failure
> so the error condition was incorrect.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>

Pushed this one to l2-mtd-2.6.git, thank you.
Adrian Hunter - Jan. 5, 2011, 11:02 a.m.
On 15/12/10 16:04, ext Artem Bityutskiy wrote:
> On Mon, 2010-12-13 at 14:20 +0200, Adrian Hunter wrote:
>>  From d27a88c5f9f18a7c38784c085889c3e1053340cf Mon Sep 17 00:00:00 2001
>> From: Adrian Hunter<adrian.hunter@nokia.com>
>> Date: Wed, 30 Dec 2009 07:40:16 +0100
>> Subject: [PATCH 1/7] mtd: OneNAND: OMAP2/3: add support for command line partitioning
>>
>> Add the ability to parse MTD partition information from the
>> kernel command line.
>>
>> Note that a pointless BUG_ON is removed, as are redundant
>> calls to 'del_mtd_partitions()' and 'del_mtd_device()'
>> because they are also done by 'onenand_release()'.
>>
>> Finally note that 'add_mtd_device()' returns 1 on failure
>> so the error condition was incorrect.
>>
>> Signed-off-by: Adrian Hunter<adrian.hunter@nokia.com>
>
> I've pushed patches 1 and 7 to l2-mtd-2.6, but patch #2 is not
> applicable. I think this is because of changes Kyungmin made recently.
> Could you please re-send patches 2 and 3 on top of the l2 tree?

I just tried to apply them to l2 and they applied fine as is.
Has something changed?  Do I have the wrong tree?

	git://git.infradead.org/users/dedekind/l2-mtd-2.6.git

>
> I guess I can apply 2 and 3 now. Patch 4 should wait for comments from
> Tony, AFAICS. Patches 5 and 6 are dependent, and hence should wait as
> well, AFAICS.
>

Patch

diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index da25a90..324402f 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -65,6 +65,10 @@  struct omap2_onenand {
 	int (*setup)(void __iomem *base, int freq);
 };
 
+#ifdef CONFIG_MTD_PARTITIONS
+static const char *part_probes[] = { "cmdlinepart", NULL,  };
+#endif
+
 static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
 {
 	struct omap2_onenand *c = data;
@@ -730,13 +734,15 @@  static int __devinit omap2_onenand_probe(struct platform_device *pdev)
 	}
 
 #ifdef CONFIG_MTD_PARTITIONS
-	if (pdata->parts != NULL)
-		r = add_mtd_partitions(&c->mtd, pdata->parts,
-				       pdata->nr_parts);
+	r = parse_mtd_partitions(&c->mtd, part_probes, &c->parts, 0);
+	if (r > 0)
+		r = add_mtd_partitions(&c->mtd, c->parts, r);
+	else if (pdata->parts != NULL)
+		r = add_mtd_partitions(&c->mtd, pdata->parts, pdata->nr_parts);
 	else
 #endif
 		r = add_mtd_device(&c->mtd);
-	if (r < 0)
+	if (r)
 		goto err_release_onenand;
 
 	platform_set_drvdata(pdev, c);
@@ -760,6 +766,7 @@  err_release_mem_region:
 err_free_cs:
 	gpmc_cs_free(c->gpmc_cs);
 err_kfree:
+	kfree(c->parts);
 	kfree(c);
 
 	return r;
@@ -769,17 +776,6 @@  static int __devexit omap2_onenand_remove(struct platform_device *pdev)
 {
 	struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
 
-	BUG_ON(c == NULL);
-
-#ifdef CONFIG_MTD_PARTITIONS
-	if (c->parts)
-		del_mtd_partitions(&c->mtd);
-	else
-		del_mtd_device(&c->mtd);
-#else
-	del_mtd_device(&c->mtd);
-#endif
-
 	onenand_release(&c->mtd);
 	if (c->dma_channel != -1)
 		omap_free_dma(c->dma_channel);
@@ -792,6 +788,7 @@  static int __devexit omap2_onenand_remove(struct platform_device *pdev)
 	iounmap(c->onenand.base);
 	release_mem_region(c->phys_base, ONENAND_IO_SIZE);
 	gpmc_cs_free(c->gpmc_cs);
+	kfree(c->parts);
 	kfree(c);
 
 	return 0;