aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2009-05-12 16:46:58 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-06-05 13:11:13 -0400
commitbf95efd41b1a760128eb25402791b0a4941eb655 (patch)
tree320dc4bb36e154ea330875ff2dee4481661059ad /drivers/mtd
parent4d964824ec826ed97bdde10bc8d8c4ce10540a98 (diff)
mtd: plat_nand: add platform probe/remove callbacks
Add optional probe and remove callbacks to the plat_nand driver. Some platforms may require additional setup, such as configuring the memory controller, before the nand device can be accessed. This patch provides an optional callback to handle this setup as well as a callback to teardown the setup. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Tested-by: Alexander Clouter <alex@digriz.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/plat_nand.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 47a2105b9671..22e0ce788419 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -72,6 +72,13 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
72 72
73 platform_set_drvdata(pdev, data); 73 platform_set_drvdata(pdev, data);
74 74
75 /* Handle any platform specific setup */
76 if (pdata->ctrl.probe) {
77 res = pdata->ctrl.probe(pdev);
78 if (res)
79 goto out;
80 }
81
75 /* Scan to find existance of the device */ 82 /* Scan to find existance of the device */
76 if (nand_scan(&data->mtd, 1)) { 83 if (nand_scan(&data->mtd, 1)) {
77 res = -ENXIO; 84 res = -ENXIO;
@@ -101,6 +108,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
101 108
102 nand_release(&data->mtd); 109 nand_release(&data->mtd);
103out: 110out:
111 if (pdata->ctrl.remove)
112 pdata->ctrl.remove(pdev);
104 platform_set_drvdata(pdev, NULL); 113 platform_set_drvdata(pdev, NULL);
105 iounmap(data->io_base); 114 iounmap(data->io_base);
106 kfree(data); 115 kfree(data);
@@ -113,15 +122,15 @@ out:
113static int __devexit plat_nand_remove(struct platform_device *pdev) 122static int __devexit plat_nand_remove(struct platform_device *pdev)
114{ 123{
115 struct plat_nand_data *data = platform_get_drvdata(pdev); 124 struct plat_nand_data *data = platform_get_drvdata(pdev);
116#ifdef CONFIG_MTD_PARTITIONS
117 struct platform_nand_data *pdata = pdev->dev.platform_data; 125 struct platform_nand_data *pdata = pdev->dev.platform_data;
118#endif
119 126
120 nand_release(&data->mtd); 127 nand_release(&data->mtd);
121#ifdef CONFIG_MTD_PARTITIONS 128#ifdef CONFIG_MTD_PARTITIONS
122 if (data->parts && data->parts != pdata->chip.partitions) 129 if (data->parts && data->parts != pdata->chip.partitions)
123 kfree(data->parts); 130 kfree(data->parts);
124#endif 131#endif
132 if (pdata->ctrl.remove)
133 pdata->ctrl.remove(pdev);
125 iounmap(data->io_base); 134 iounmap(data->io_base);
126 kfree(data); 135 kfree(data);
127 136