From patchwork Wed Nov 28 10:26:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 1814981 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 1F61C3FC54 for ; Wed, 28 Nov 2012 10:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753997Ab2K1K0I (ORCPT ); Wed, 28 Nov 2012 05:26:08 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:11802 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753868Ab2K1K0F (ORCPT ); Wed, 28 Nov 2012 05:26:05 -0500 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 <0ME700FJE0ZFFKZ0@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Wed, 28 Nov 2012 19:26:03 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.51]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id D3.6E.12699.BB6E5B05; Wed, 28 Nov 2012 19:26:03 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-a9-50b5e6bb17ab Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 83.6E.12699.BB6E5B05; Wed, 28 Nov 2012 19:26:03 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ME7007580ZFOCA0@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Wed, 28 Nov 2012 19:26:03 +0900 (KST) From: Seungwon Jeon To: linux-mmc@vger.kernel.org Cc: 'Chris Ball' , 'Will Newton' , 'James Hogan' , 'Jaehoon Chung' References: In-reply-to: Subject: [PATCH 1/2] mmc: dw_mmc: use devres functions in dw_mmc Date: Wed, 28 Nov 2012 19:26:03 +0900 Message-id: <001b01cdcd52$c4b85700$4e290500$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac03z3aCvVFr8FaITt2vKVQKst76fw3Ogf7QC4iI1hAMB9K34A== Content-language: ko x-cr-hashedpuzzle: FdHK Fn7k Ftts Gd4Z HFEi Nd/A OH4W OcpJ PINQ gZDG hQDT pmDx qEBQ wK42 wyd0 w/XT; 5; YwBqAGIAQABsAGEAcAB0AG8AcAAuAG8AcgBnADsAagBhAG0AZQBzAC4AaABvAGcAYQBuAEAAaQBtAGcAdABlAGMALgBjAG8AbQA7AGoAaAA4ADAALgBjAGgAdQBuAGcAQABzAGEAbQBzAHUAbgBnAC4AYwBvAG0AOwBsAGkAbgB1AHgALQBtAG0AYwBAAHYAZwBlAHIALgBrAGUAcgBuAGUAbAAuAG8AcgBnADsAdwBpAGwAbAAuAG4AZQB3AHQAbwBuAEAAaQBtAGcAdABlAGMALgBjAG8AbQA=; Sosha1_v1; 7; {E59A72B1-DDF5-4F91-9291-F9A6029B6A9D}; dABnAGkAaAAuAGoAdQBuAEAAcwBhAG0AcwB1AG4AZwAuAGMAbwBtAA==; Wed, 28 Nov 2012 10:25:55 GMT; WwBQAEEAVABDAEgAIAAxAC8AMgBdACAAbQBtAGMAOgAgAGQAdwBfAG0AbQBjADoAIAB1AHMAZQAgAGQAZQB2AHIAZQBzACAAZgB1AG4AYwB0AGkAbwBuAHMAIABpAG4AIABkAHcAXwBtAG0AYwA= x-cr-puzzleid: {E59A72B1-DDF5-4F91-9291-F9A6029B6A9D} DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsVy+t8zY93dz7YGGMx4oGFx5H8/owOjx+dN cgGMUVw2Kak5mWWpRfp2CVwZCy9/Zi/4rFgx59R0pgbGu9JdjJwcEgImEtvvvmGFsMUkLtxb z9bFyMUhJLCMUeLZiUdMMEXL13WxQCSmM0ocffWDGcKZxSSx/tBisCo2AS2Jv2/eMIPYIgKy Ej//XAAbxSwwn1HixYErQDs4gDq4JVY3B4HUcArwSKz70wlWLyzgIHH3+BKwM1gEVCV6prSB zeQVsJVY/XwxM4QtKPFj8j0WkDHMAuoSU6bkgoSZBeQlNq95ywwSlgAKP/qrC3GBk8SX3dtZ IEpEJPa9eMcIco2EwAZWid/retkhHjOVeN43BWqtgMS3yYdYIObISmw6wAxRf4hd4uNmiLck BCQlDq64wTKBUWoWkotmIVw0C8lFs5CsXsDIsopRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMj JBKldzCuarA4xCjAwajEw+vguDVAiDWxrLgy9xCjBAezkggv8yOgEG9KYmVValF+fFFpTmrx IUYfoMMnMkuJJucDk0ReSbyhsbGJmYmpibmlqbkpDmElcd5mj5QAIYH0xJLU7NTUgtQimHFM HJxSDYwqs1tyN81uWrpne59cuam3QvmUT8tfdVfeC6vlep/z86KcoseDzYIHBJ7aHAirlQ3l WpDBvElOXWjBU88Qu7SZx1LmBZvb5EV8W3lz7fv30955neHbv1uTsdXnUEerjdlmHQnJKbd2 S9xT00i1CA09Gf53danzHY0SOaaYM44rl5fd6FBuuaHEUpyRaKjFXFScCABBne2p8QIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42I5/e+xoO7uZ1sDDPYdVrE48r+f0YHR4/Mm uQDGqAZGm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zByg qUoKZYk5pUChgMTiYiV9O0wTQkPcdC1gGiN0fUOC4HqMDNBAwjrGjIWXP7MXfFasmHNqOlMD 413pLkZODgkBE4nl67pYIGwxiQv31rN1MXJxCAlMZ5Q4+uoHM4Qzi0li/aHFTCBVbAJaEn/f vGEGsUUEZCV+/rkA1sEsMJ9R4sWBK6xdjBxAHdwSq5uDQGo4BXgk1v3pBKsXFnCQuHt8CSuI zSKgKtEzpQ1sJq+ArcTq54uZIWxBiR+T77GAjGEWUJeYMiUXJMwsIC+xec1bZpCwBFD40V9d iAucJL7s3s4CUSIise/FO0aQayQENrBK/F7Xyw7xmKnE874prBMYRWYh2TALYcMsJBtmIRm1 gJFlFaNoakFyQXFSeq6RXnFibnFpXrpecn7uJkZwnD+T3sG4qsHiEKMAB6MSD6+D49YAIdbE suLK3EOMEhzMSiK8zI+AQrwpiZVVqUX58UWlOanFhxh9gP6fyCwlmpwPTEF5JfGGxiZmRpZG ZhZGJubmOISVxHmbPVIChATSE0tSs1NTC1KLYMYxcXBKNTCyPjqn9/zuz4jGfnWh7NrrF45M UF+ZKBI0eVZkQp1T6J0EBZ2f59k6VnRGin38s+fnme1xk49pt4itNVgmvO5U0eut63PjmuQn 6FivqY36ylZ3UP6fo4adzP5ZJ34syXvicTTxY373ROXtgeyJfBwHfmxbW652fN7NAx5XHcs4 hS13/lEJ/CmnxFKckWioxVxUnAgAAkqsrCADAAA= X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Use managed device resource functions for easy handling. This makes driver simpler in the routine of error and exit. Signed-off-by: Seungwon Jeon Acked-by: James Hogan --- drivers/mmc/host/dw_mmc.c | 43 ++++++++++++++----------------------------- 1 files changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 7342029..6785d62 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1914,7 +1914,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) #endif /* CONFIG_MMC_DW_IDMAC */ } - host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); + host->vmmc = devm_regulator_get(mmc_dev(mmc), "vmmc"); if (IS_ERR(host->vmmc)) { pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); host->vmmc = NULL; @@ -1963,7 +1963,7 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id) static void dw_mci_init_dma(struct dw_mci *host) { /* Alloc memory for sg translation */ - host->sg_cpu = dma_alloc_coherent(host->dev, PAGE_SIZE, + host->sg_cpu = dmam_alloc_coherent(host->dev, PAGE_SIZE, &host->sg_dma, GFP_KERNEL); if (!host->sg_cpu) { dev_err(host->dev, "%s: could not alloc DMA memory\n", @@ -2112,26 +2112,24 @@ int dw_mci_probe(struct dw_mci *host) return -ENODEV; } - host->biu_clk = clk_get(host->dev, "biu"); + host->biu_clk = devm_clk_get(host->dev, "biu"); if (IS_ERR(host->biu_clk)) { dev_dbg(host->dev, "biu clock not available\n"); } else { ret = clk_prepare_enable(host->biu_clk); if (ret) { dev_err(host->dev, "failed to enable biu clock\n"); - clk_put(host->biu_clk); return ret; } } - host->ciu_clk = clk_get(host->dev, "ciu"); + host->ciu_clk = devm_clk_get(host->dev, "ciu"); if (IS_ERR(host->ciu_clk)) { dev_dbg(host->dev, "ciu clock not available\n"); } else { ret = clk_prepare_enable(host->ciu_clk); if (ret) { dev_err(host->dev, "failed to enable ciu clock\n"); - clk_put(host->ciu_clk); goto err_clk_biu; } } @@ -2233,7 +2231,8 @@ int dw_mci_probe(struct dw_mci *host) if (!host->card_workqueue) goto err_dmaunmap; INIT_WORK(&host->card_work, dw_mci_work_routine_card); - ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); + ret = devm_request_irq(host->dev, host->irq, dw_mci_interrupt, + host->irq_flags, "dw-mci", host); if (ret) goto err_workqueue; @@ -2271,7 +2270,7 @@ int dw_mci_probe(struct dw_mci *host) } else { dev_dbg(host->dev, "attempted to initialize %d slots, " "but failed on all\n", host->num_slots); - goto err_init_slot; + goto err_workqueue; } /* @@ -2291,33 +2290,24 @@ int dw_mci_probe(struct dw_mci *host) return 0; -err_init_slot: - free_irq(host->irq, host); - err_workqueue: destroy_workqueue(host->card_workqueue); err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); - dma_free_coherent(host->dev, PAGE_SIZE, - host->sg_cpu, host->sg_dma); - if (host->vmmc) { + if (host->vmmc) regulator_disable(host->vmmc); - regulator_put(host->vmmc); - } err_clk_ciu: - if (!IS_ERR(host->ciu_clk)) { + if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); - clk_put(host->ciu_clk); - } + err_clk_biu: - if (!IS_ERR(host->biu_clk)) { + if (!IS_ERR(host->biu_clk)) clk_disable_unprepare(host->biu_clk); - clk_put(host->biu_clk); - } + return ret; } EXPORT_SYMBOL(dw_mci_probe); @@ -2339,24 +2329,19 @@ void dw_mci_remove(struct dw_mci *host) mci_writel(host, CLKENA, 0); mci_writel(host, CLKSRC, 0); - free_irq(host->irq, host); destroy_workqueue(host->card_workqueue); - dma_free_coherent(host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); - if (host->vmmc) { + if (host->vmmc) regulator_disable(host->vmmc); - regulator_put(host->vmmc); - } if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); + if (!IS_ERR(host->biu_clk)) clk_disable_unprepare(host->biu_clk); - clk_put(host->ciu_clk); - clk_put(host->biu_clk); } EXPORT_SYMBOL(dw_mci_remove);