From patchwork Mon Sep 17 18:16:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 1469171 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 95796DF2D8 for ; Mon, 17 Sep 2012 17:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757115Ab2IQR4p (ORCPT ); Mon, 17 Sep 2012 13:56:45 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:13259 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757091Ab2IQR4o (ORCPT ); Mon, 17 Sep 2012 13:56:44 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAI005339UEK530@mailout3.samsung.com>; Tue, 18 Sep 2012 02:56:42 +0900 (KST) X-AuditID: cbfee61b-b7f2b6d000000f14-d4-5057645ad283 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id FC.5A.03860.A5467505; Tue, 18 Sep 2012 02:56:42 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MAI00MTJ9U8PO50@mmp1.samsung.com>; Tue, 18 Sep 2012 02:56:42 +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 v6 2/9] mmc: dw_mmc: Use devm_* functions in dw_mmc platform driver Date: Mon, 17 Sep 2012 23:46:36 +0530 Message-id: <1347905803-22742-3-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 In-reply-to: <1347905803-22742-1-git-send-email-thomas.abraham@linaro.org> References: <1347905803-22742-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBJMWRmVeSWpSXmKPExsVy+t9jAd2olPAAg53rrCyO/O9ntJhxfh+T A5PH501yAYxRXDYpqTmZZalF+nYJXBkPn/9jLZjEVzHp0UK2BsZD3F2MnBwSAiYS0ya8YoSw xSQu3FvP1sXIxSEksIhR4uyT/4wQThuTxIVZB9lAqtgEDCQeLXzHDmKLCDhJLJk7gRmkiFmg kUli48KdYEXCAqESK/ceAbNZBFQlXkx4DraCV8BTYtrBHiaIdUoSG3qPgtmcAl4S07cfAhsq BFSzd8VslgmMvAsYGVYxiqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBPv/mfQOxlUNFocYBTgY lXh4E4LCA4RYE8uKK3MPMUpwMCuJ8N4WAArxpiRWVqUW5ccXleakFh9ilOZgURLnFf4UGCAk kJ5YkpqdmlqQWgSTZeLglGpglJipKJd+tUK3qf3e7udLFraZaa6su8f06NbBGCk73sIrW79z aAWHXV7rpct1LDQ4w5X9auIDh/NOuny1j2c9zpboPtZ+/dwf//srojfy1Wxj2L+598+/eDbZ 54ZZtosU+p/I8NxbxOW2e/b5kzPzT4UerE/LY7C052df4me+4fKSu/39Pxw+KrEUZyQaajEX FScCAFAmeLf7AQAA 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; }