From patchwork Thu Mar 5 23:58:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartley Sweeten X-Patchwork-Id: 24132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C86A4DDEE7 for ; Fri, 6 Mar 2009 11:02:21 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LfNU1-0004Oz-B9; Fri, 06 Mar 2009 00:00:09 +0000 Received: from exprod6og107.obsmtp.com ([64.18.1.208]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1LfNSc-0004On-Uu for linux-mtd@lists.infradead.org; Thu, 05 Mar 2009 23:58:46 +0000 Received: from source ([63.240.6.3]) (using TLSv1) by exprod6ob107.postini.com ([64.18.5.12]) with SMTP ID DSNKSbBnMOa0d2VMynGCKEgpZmhsZylFsLJo@postini.com; Thu, 05 Mar 2009 15:58:42 PST Received: from D01SMTP04.Mi8.com ([172.16.1.243]) by Outbound02.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 5 Mar 2009 18:58:39 -0500 Received: from mi8nycmail19.Mi8.com ([172.16.7.219]) by D01SMTP04.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 5 Mar 2009 18:58:39 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: [PATCH] mtd: plat_nand: add platform probe/remove callbacks Date: Thu, 5 Mar 2009 18:58:12 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] mtd: plat_nand: add platform probe/remove callbacks Thread-Index: Acmd7j4oCoWej2IDQqOIqGQ4v5RlKw== From: "hartleys" To: X-OriginalArrivalTime: 05 Mar 2009 23:58:39.0666 (UTC) FILETIME=[4E354120:01C99DEE] X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [64.18.1.208 listed in list.dnswl.org] Cc: Andrew Morton , linux-mtd@lists.infradead.org, Alexander Clouter , vitalywool@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Tested-By: Alexander Clouter --- * @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); 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