From patchwork Tue Aug 5 13:09:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raman X-Patchwork-Id: 4678941 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A8059F375 for ; Tue, 5 Aug 2014 13:10:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A77A20173 for ; Tue, 5 Aug 2014 13:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A90A20172 for ; Tue, 5 Aug 2014 13:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754562AbaHENJ6 (ORCPT ); Tue, 5 Aug 2014 09:09:58 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:44875 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbaHENJ4 (ORCPT ); Tue, 5 Aug 2014 09:09:56 -0400 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1XEeV2-0004Pu-89 from Vignesh_Raman@mentor.com ; Tue, 05 Aug 2014 06:09:56 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 5 Aug 2014 06:09:56 -0700 Received: from m4700.inp-wifi.mentorg.com (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Tue, 5 Aug 2014 06:09:55 -0700 From: Vignesh Raman To: , , , CC: Subject: [PATCH v2 1/2] dma: imx-sdma: use module_platform_driver for SDMA driver Date: Tue, 5 Aug 2014 18:39:41 +0530 Message-ID: <1407244182-27302-2-git-send-email-Vignesh_Raman@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1407244182-27302-1-git-send-email-Vignesh_Raman@mentor.com> References: <1407244182-27302-1-git-send-email-Vignesh_Raman@mentor.com> MIME-Version: 1.0 X-OriginalArrivalTime: 05 Aug 2014 13:09:56.0110 (UTC) FILETIME=[8D7532E0:01CFB0AE] Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently there is no module_exit declared in SDMA driver, so that once sdma module is inserted, it's shown with permanent attribute by lsmod, and it can't be removed. Use module_platform_driver to register/unregister SDMA driver and modify SDMA's remove operation, to make SDMA driver possible to be removed. Signed-off-by: Jiada Wang --- drivers/dma/imx-sdma.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 14867e3..5cefc7d 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1596,6 +1596,8 @@ static int __init sdma_probe(struct platform_device *pdev) sdma->dma_device.dev->dma_parms = &sdma->dma_parms; dma_set_max_seg_size(sdma->dma_device.dev, 65535); + platform_set_drvdata(pdev, sdma); + ret = dma_async_device_register(&sdma->dma_device); if (ret) { dev_err(&pdev->dev, "unable to register\n"); @@ -1633,7 +1635,20 @@ err_irq: static int sdma_remove(struct platform_device *pdev) { - return -EBUSY; + struct sdma_engine *sdma = platform_get_drvdata(pdev); + struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); + int irq = platform_get_irq(pdev, 0); + + dma_async_device_unregister(&sdma->dma_device); + kfree(sdma->script_addrs); + free_irq(irq, sdma); + iounmap(sdma->regs); + release_mem_region(iores->start, resource_size(iores)); + kfree(sdma); + + platform_set_drvdata(pdev, NULL); + dev_info(&pdev->dev, "Removed...\n"); + return 0; } static struct platform_driver sdma_driver = { @@ -1643,13 +1658,10 @@ static struct platform_driver sdma_driver = { }, .id_table = sdma_devtypes, .remove = sdma_remove, + .probe = sdma_probe, }; -static int __init sdma_module_init(void) -{ - return platform_driver_probe(&sdma_driver, sdma_probe); -} -module_init(sdma_module_init); +module_platform_driver(sdma_driver); MODULE_AUTHOR("Sascha Hauer, Pengutronix "); MODULE_DESCRIPTION("i.MX SDMA driver");