aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand/omap2.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@nokia.com>2009-12-30 01:40:16 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-01-06 10:22:45 -0500
commit263a8c8635445c0ede3cb22c98a1a12da4672ebc (patch)
treee7b4ca9b40573e226d5151f51efd24904415ef83 /drivers/mtd/onenand/omap2.c
parentb7b1a29d94c17e4341856381bccb4d17495bea60 (diff)
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> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/onenand/omap2.c')
-rw-r--r--drivers/mtd/onenand/omap2.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index da25a90af4a4..324402fcdedc 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -65,6 +65,10 @@ struct omap2_onenand {
65 int (*setup)(void __iomem *base, int freq); 65 int (*setup)(void __iomem *base, int freq);
66}; 66};
67 67
68#ifdef CONFIG_MTD_PARTITIONS
69static const char *part_probes[] = { "cmdlinepart", NULL, };
70#endif
71
68static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data) 72static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
69{ 73{
70 struct omap2_onenand *c = data; 74 struct omap2_onenand *c = data;
@@ -730,13 +734,15 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
730 } 734 }
731 735
732#ifdef CONFIG_MTD_PARTITIONS 736#ifdef CONFIG_MTD_PARTITIONS
733 if (pdata->parts != NULL) 737 r = parse_mtd_partitions(&c->mtd, part_probes, &c->parts, 0);
734 r = add_mtd_partitions(&c->mtd, pdata->parts, 738 if (r > 0)
735 pdata->nr_parts); 739 r = add_mtd_partitions(&c->mtd, c->parts, r);
740 else if (pdata->parts != NULL)
741 r = add_mtd_partitions(&c->mtd, pdata->parts, pdata->nr_parts);
736 else 742 else
737#endif 743#endif
738 r = add_mtd_device(&c->mtd); 744 r = add_mtd_device(&c->mtd);
739 if (r < 0) 745 if (r)
740 goto err_release_onenand; 746 goto err_release_onenand;
741 747
742 platform_set_drvdata(pdev, c); 748 platform_set_drvdata(pdev, c);
@@ -760,6 +766,7 @@ err_release_mem_region:
760err_free_cs: 766err_free_cs:
761 gpmc_cs_free(c->gpmc_cs); 767 gpmc_cs_free(c->gpmc_cs);
762err_kfree: 768err_kfree:
769 kfree(c->parts);
763 kfree(c); 770 kfree(c);
764 771
765 return r; 772 return r;
@@ -769,17 +776,6 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
769{ 776{
770 struct omap2_onenand *c = dev_get_drvdata(&pdev->dev); 777 struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
771 778
772 BUG_ON(c == NULL);
773
774#ifdef CONFIG_MTD_PARTITIONS
775 if (c->parts)
776 del_mtd_partitions(&c->mtd);
777 else
778 del_mtd_device(&c->mtd);
779#else
780 del_mtd_device(&c->mtd);
781#endif
782
783 onenand_release(&c->mtd); 779 onenand_release(&c->mtd);
784 if (c->dma_channel != -1) 780 if (c->dma_channel != -1)
785 omap_free_dma(c->dma_channel); 781 omap_free_dma(c->dma_channel);
@@ -792,6 +788,7 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
792 iounmap(c->onenand.base); 788 iounmap(c->onenand.base);
793 release_mem_region(c->phys_base, ONENAND_IO_SIZE); 789 release_mem_region(c->phys_base, ONENAND_IO_SIZE);
794 gpmc_cs_free(c->gpmc_cs); 790 gpmc_cs_free(c->gpmc_cs);
791 kfree(c->parts);
795 kfree(c); 792 kfree(c);
796 793
797 return 0; 794 return 0;