diff options
-rw-r--r-- | drivers/mtd/nand/plat_nand.c | 13 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 7 |
2 files changed, 18 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); |
103 | out: | 110 | out: |
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: | |||
113 | static int __devexit plat_nand_remove(struct platform_device *pdev) | 122 | static 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 | ||
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 0e35375ea795..7f2d69356554 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -577,8 +577,13 @@ struct platform_nand_chip { | |||
577 | void *priv; | 577 | void *priv; |
578 | }; | 578 | }; |
579 | 579 | ||
580 | /* Keep gcc happy */ | ||
581 | struct platform_device; | ||
582 | |||
580 | /** | 583 | /** |
581 | * struct platform_nand_ctrl - controller level device structure | 584 | * struct platform_nand_ctrl - controller level device structure |
585 | * @probe: platform specific function to probe/setup hardware | ||
586 | * @remove: platform specific function to remove/teardown hardware | ||
582 | * @hwcontrol: platform specific hardware control structure | 587 | * @hwcontrol: platform specific hardware control structure |
583 | * @dev_ready: platform specific function to read ready/busy pin | 588 | * @dev_ready: platform specific function to read ready/busy pin |
584 | * @select_chip: platform specific chip select function | 589 | * @select_chip: platform specific chip select function |
@@ -591,6 +596,8 @@ struct platform_nand_chip { | |||
591 | * All fields are optional and depend on the hardware driver requirements | 596 | * All fields are optional and depend on the hardware driver requirements |
592 | */ | 597 | */ |
593 | struct platform_nand_ctrl { | 598 | struct platform_nand_ctrl { |
599 | int (*probe)(struct platform_device *pdev); | ||
600 | void (*remove)(struct platform_device *pdev); | ||
594 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); | 601 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); |
595 | int (*dev_ready)(struct mtd_info *mtd); | 602 | int (*dev_ready)(struct mtd_info *mtd); |
596 | void (*select_chip)(struct mtd_info *mtd, int chip); | 603 | void (*select_chip)(struct mtd_info *mtd, int chip); |