@@ -70,6 +70,13 @@ static int __init plat_nand_probe(struct
platform_device *pdev)
platform_set_drvdata(pdev, data);
+ /* Handle any platform specific setup */
+ if (pdata->ctrl.setup) {
+ res = pdata->ctrl.setup(pdev);
+ if (res)
+ goto out;
+ }
+
/* Scan to find existance of the device */
if (nand_scan(&data->mtd, 1)) {
res = -ENXIO;
@@ -99,6 +106,8 @@ static int __init plat_nand_probe(struct
platform_device *pdev)
nand_release(&data->mtd);
out:
+ if (pdata->ctrl.teardown)
+ pdata->ctrl.teardown(pdev);
platform_set_drvdata(pdev, NULL);
iounmap(data->io_base);
kfree(data);
@@ -111,15 +120,15 @@ out:
static int __devexit plat_nand_remove(struct platform_device *pdev)
{
struct plat_nand_data *data = platform_get_drvdata(pdev);
-#ifdef CONFIG_MTD_PARTITIONS
struct platform_nand_data *pdata = pdev->dev.platform_data;
-#endif
nand_release(&data->mtd);
#ifdef CONFIG_MTD_PARTITIONS
if (data->parts && data->parts != pdata->chip.partitions)
kfree(data->parts);
#endif
+ if (pdata->ctrl.teardown)
+ pdata->ctrl.teardown(pdev);
iounmap(data->io_base);
kfree(data);
@@ -579,6 +579,8 @@ struct platform_nand_chip {
/**
* struct platform_nand_ctrl - controller level device structure
+ * @setup: platform specific function to setup hardware
+ * @teardown: platform specific function to teardown hardware
* @hwcontrol: platform specific hardware control structure
* @dev_ready: platform specific function to read ready/busy
pin
Add optional setup and teardown 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> --- * @select_chip: platform specific chip select function @@ -589,6 +591,8 @@ struct platform_nand_chip { * All fields are optional and depend on the hardware driver requirements */ struct platform_nand_ctrl { + int (*setup)(struct platform_device *pdev); + void (*teardown)(struct platform_device *pdev); void (*hwcontrol)(struct mtd_info *mtd, int cmd); int (*dev_ready)(struct mtd_info *mtd); void (*select_chip)(struct mtd_info *mtd, int chip);