From patchwork Sun Aug 26 11:52:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 1374751 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7848D3FD40 for ; Sun, 26 Aug 2012 11:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753551Ab2HZLeS (ORCPT ); Sun, 26 Aug 2012 07:34:18 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:22665 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156Ab2HZLeR (ORCPT ); Sun, 26 Aug 2012 07:34:17 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9D008SU1H2OB00@mailout4.samsung.com>; Sun, 26 Aug 2012 20:34:16 +0900 (KST) X-AuditID: cbfee61b-b7faf6d00000476a-ab-503a09b7f8ce Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 51.E9.18282.7B90A305; Sun, 26 Aug 2012 20:34:16 +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 <0M9D00AQQ1GN7UA0@mmp1.samsung.com>; Sun, 26 Aug 2012 20:34:15 +0900 (KST) From: Thomas Abraham To: linux-mmc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org Cc: 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 v4 2/9] mmc: dw_mmc: Use devm_* functions in dw_mmc platform driver Date: Sun, 26 Aug 2012 17:22:00 +0530 Message-id: <1345981927-26359-3-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 In-reply-to: <1345981927-26359-1-git-send-email-thomas.abraham@linaro.org> References: <1345981927-26359-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBJMWRmVeSWpSXmKPExsVy+t9jAd0dnFYBBjd/M1sc+d/PaDHj/D4m ByaPz5vkAhijuGxSUnMyy1KL9O0SuDJeLtvPVHCVt2Lhr33sDYzd3F2MnBwSAiYSz39MZYWw xSQu3FvP1sXIxSEksIhR4u/dB6wQThuTRN+/fYwgVWwCBhKPFr5jB7FFBJwklsydwAxSxCzw klFi5q6ZbCAJYYFQiY3z+sAaWARUJc5dmMQCYvMKeEp0/rsPtU5JYkPvUSYQm1PAS+LGolaw oUJANcdnfGecwMi7gJFhFaNoakFyQXFSeq6RXnFibnFpXrpecn7uJkaw/59J72Bc1WBxiFGA g1GJh1eg1DJAiDWxrLgy9xCjBAezkgjv9/1AId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rz8fYYB QgLpiSWp2ampBalFMFkmDk6pBkYlr8+CUi6aOY+3iCz4m+Yw0WnTkiSnLd8ZrzUuM70X+HBL trnP7PkzxT+/VslY/Gny4hqJh11eb2Nk73HnW3lPapTgzbLgOje78/KR89xhZR8Fin4+tky3 2XJ9hi5T28dHjwo3xe5l7NtqLXu1N2+XfFDjwT7Zjzo/XG6lb9qS6Fzo4zF92lUlluKMREMt 5qLiRAAWqbvw+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 --- 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 9a63299..1488b17 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -27,38 +27,27 @@ static int 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 __exit dw_mci_pltfm_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); dw_mci_remove(host); - iounmap(host->regs); - kfree(host); return 0; }