* [PATCH] mtd: plat_nand: add platform probe/remove callbacks
@ 2009-03-05 23:58 hartleys
2009-03-06 21:24 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: hartleys @ 2009-03-05 23:58 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-mtd, Alexander Clouter, Andrew Morton, vitalywool
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.
This patch was originally submitted to linux-mtd but it was
suggested I post it here for a broader review.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Tested-By: Alexander Clouter <alex@digriz.org.uk>
---
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 75f9f48..600fbe9 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -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.probe) {
+ res = pdata->ctrl.probe(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.remove)
+ pdata->ctrl.remove(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.remove)
+ pdata->ctrl.remove(pdev);
iounmap(data->io_base);
kfree(data);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index db5b63d..4c88163 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -577,8 +577,13 @@ struct platform_nand_chip {
void *priv;
};
+/* Keep gcc happy */
+struct platform_device;
+
/**
* struct platform_nand_ctrl - controller level device structure
+ * @probe: platform specific function to probe/setup
hardware
+ * @remove: platform specific function to remove/teardown
hardware
* @hwcontrol: platform specific hardware control structure
* @dev_ready: platform specific function to read ready/busy
pin
* @select_chip: platform specific chip select function
@@ -589,6 +594,8 @@ struct platform_nand_chip {
* All fields are optional and depend on the hardware driver
requirements
*/
struct platform_nand_ctrl {
+ int (*probe)(struct platform_device *pdev);
+ void (*remove)(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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: plat_nand: add platform probe/remove callbacks
2009-03-05 23:58 [PATCH] mtd: plat_nand: add platform probe/remove callbacks hartleys
@ 2009-03-06 21:24 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2009-03-06 21:24 UTC (permalink / raw)
To: hartleys; +Cc: linux-kernel, linux-mtd, alex, vitalywool
On Thu, 5 Mar 2009 18:58:12 -0500
"hartleys" <hartleys@visionengravers.com> wrote:
> From: "hartleys" <hartleys@visionengravers.com>
You might want to change your email setup so that the above reads "H
Hartley Sweeten <hsweeten@visionengravers.com>" or whatever. Because
most patch-merging people's tools will end up marking this commit as
being from someone called "hartleys".
Alternatively, put an explicit From: line at the top of the changelog.
> To: <linux-kernel@vger.kernel.org>
> Cc: <linux-mtd@lists.infradead.org>, "Alexander Clouter" <alex@digriz.org.uk>, "Andrew Morton" <akpm@linux-foundation.org>, <vitalywool@gmail.com>
> Subject: [PATCH] mtd: plat_nand: add platform probe/remove callbacks
> Date: Thu, 5 Mar 2009 18:58:12 -0500
>
> 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.
>
> This patch was originally submitted to linux-mtd but it was
> suggested I post it here for a broader review.
Looks OK to me, but I'm an MTD ignoramus.
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
> Tested-By: Alexander Clouter <alex@digriz.org.uk>
>
> ---
>
> diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
> index 75f9f48..600fbe9 100644
The patch was quite wordwrapped. Please fix your email client for next
time.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-06 21:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-05 23:58 [PATCH] mtd: plat_nand: add platform probe/remove callbacks hartleys
2009-03-06 21:24 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox