From patchwork Wed Aug 29 10:48:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 1384471 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8DE37DF215 for ; Wed, 29 Aug 2012 10:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793Ab2H2KaJ (ORCPT ); Wed, 29 Aug 2012 06:30:09 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:8318 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752791Ab2H2KaI (ORCPT ); Wed, 29 Aug 2012 06:30:08 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9I00F4LIHIWE11@mailout4.samsung.com>; Wed, 29 Aug 2012 19:30:07 +0900 (KST) X-AuditID: cbfee61a-b7fc66d0000043b7-47-503def2f0034 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 9D.40.17335.F2FED305; Wed, 29 Aug 2012 19:30:07 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M9I004F3IHPXG70@mmp2.samsung.com>; Wed, 29 Aug 2012 19:30:07 +0900 (KST) From: Thomas Abraham To: linux-mmc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org Cc: will.newton@imgtec.com, cjb@laptop.org, grant.likely@secretlab.ca, rob.herring@calxeda.com, linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com, girish.shivananjappa@linaro.org, jh80.chung@samsung.com, tgih.jun@samsung.com, patches@linaro.org Subject: [PATCH v5 2/9] mmc: dw_mmc: Use devm_* functions in dw_mmc platform driver Date: Wed, 29 Aug 2012 16:18:08 +0530 Message-id: <1346237295-7116-3-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 In-reply-to: <1346237295-7116-1-git-send-email-thomas.abraham@linaro.org> References: <1346237295-7116-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBJMWRmVeSWpSXmKPExsVy+t9jQV3997YBBqfXy1oc+d/PaDHj/D4m ByaPz5vkAhijuGxSUnMyy1KL9O0SuDIePv/HWjCJr2LSo4VsDYyHuLsYOTkkBEwk5jxfywhh i0lcuLeerYuRi0NIYDqjRMuMeUwQThuTROOR7awgVWwCBhKPFr5jB7FFBJwklsydwAxSxCzQ yCSxceFONpCEsECoxKHb98BsFgFViV2HWphAbF4BD4k7nevZIdYpSWzoPQoW5xTwlHi38gpY vRBQze97K9kmMPIuYGRYxSiaWpBcUJyUnmuoV5yYW1yal66XnJ+7iRHs/2dSOxhXNlgcYhTg YFTi4b3AbRsgxJpYVlyZe4hRgoNZSYQ39RVQiDclsbIqtSg/vqg0J7X4EKM0B4uSOC9/n2GA kEB6YklqdmpqQWoRTJaJg1OqgVHh7uv3cZPmGD0IaTj/uSekNnTOvGkBbm92L+Ppq0h9suel 9aPr5fcnhplvOXM+TGDOY48d6zkjzoY33DZRZ3jvd2X3swO7HD/3MZ46/H4ds6ioUcec6ndn mkwkVnCYH/59wihmTmJ/XdCSS4W7mTMXz280jdyYv9posZ5PpHBj1Ssn97lisguVWIozEg21 mIuKEwFqMqV1+wEAAA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Use devm_* managed functions for simpler error handling. Signed-off-by: Thomas Abraham Acked-by: Will Newton --- drivers/mmc/host/dw_mmc-pltfm.c | 29 ++++++++--------------------- 1 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index 528d37b..ce7be1a 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -27,38 +27,27 @@ static int __devinit dw_mci_pltfm_probe(struct platform_device *pdev) struct resource *regs; int ret; - host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); + host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL); if (!host) return -ENOMEM; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!regs) { - ret = -ENXIO; - goto err_free; - } + if (!regs) + return -ENXIO; host->irq = platform_get_irq(pdev, 0); - if (host->irq < 0) { - ret = host->irq; - goto err_free; - } + if (host->irq < 0) + return host->irq; host->dev = &pdev->dev; host->irq_flags = 0; host->pdata = pdev->dev.platform_data; - ret = -ENOMEM; - host->regs = ioremap(regs->start, resource_size(regs)); + host->regs = devm_request_and_ioremap(&pdev->dev, regs); if (!host->regs) - goto err_free; + return -ENOMEM; + platform_set_drvdata(pdev, host); ret = dw_mci_probe(host); - if (ret) - goto err_out; - return ret; -err_out: - iounmap(host->regs); -err_free: - kfree(host); return ret; } @@ -68,8 +57,6 @@ static int __devexit dw_mci_pltfm_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); dw_mci_remove(host); - iounmap(host->regs); - kfree(host); return 0; }