From patchwork Wed Nov 2 11:28:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 9408959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C45F60585 for ; Wed, 2 Nov 2016 11:28:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34E7A29A87 for ; Wed, 2 Nov 2016 11:28:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26D3029F65; Wed, 2 Nov 2016 11:28:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D81B29A87 for ; Wed, 2 Nov 2016 11:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750800AbcKBL2d (ORCPT ); Wed, 2 Nov 2016 07:28:33 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:41058 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbcKBL2d (ORCPT ); Wed, 2 Nov 2016 07:28:33 -0400 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OG001TEDIJIJB30@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Wed, 02 Nov 2016 20:28:30 +0900 (KST) X-AuditID: cbfee61a-f79926d000005981-fb-5819cddec5b8 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 2C.58.22913.EDDC9185; Wed, 2 Nov 2016 20:28:30 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OG000K1UIJ8AQ00@mmp1.samsung.com>; Wed, 02 Nov 2016 20:28:30 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Cc: krzk@kernel.org, m.szyprowski@samsung.com, alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, sbkim73@samsung.com, Sylwester Nawrocki Subject: [PATCH] ASoC: samsung: pcm: Conversion to use devm_ioremap_resource() Date: Wed, 02 Nov 2016 12:28:17 +0100 Message-id: <1478086097-24523-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLLMWRmVeSWpSXmKPExsVy+t9jAd17ZyUjDLY8Ura4cvEQk8XUh0/Y LM6f38BuMeP8PiaLtUfuslscftPOanFxxRcmB3aPDZ+b2Dw2repk8+jbsorR4/MmuQCWKDeb jNTElNQihdS85PyUzLx0W6XQEDddCyWFvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4B7gHK+nb JbhlPG+wLFgiU9H2w6KBcbp4FyMnh4SAicSkOy/YIWwxiQv31rOB2EICSxklrt4162LkArJ/ MUp8mH6ABSTBJmAo0Xu0jxHEFgFquD2nkxnEZhbYzCjRsioJxBYW8JNYtu0WK4jNIqAq8WLr dLChvAJuEk+uzmeGWCYncfLYZNYJjNwLGBlWMUqkFiQXFCel5xrmpZbrFSfmFpfmpesl5+du YgQH5TOpHYwHd7kfYhTgYFTi4Z2wRCJCiDWxrLgy9xCjBAezkgjvqsOSEUK8KYmVValF+fFF pTmpxYcYTYEOmMgsJZqcD4yYvJJ4QxNzE3NjAwtzS0sTIyVx3sbZz8KFBNITS1KzU1MLUotg +pg4OKUaGOttn4TMPXjp9LHTd4OyW4xPND3m2LzwtNuOmtLNL/5Zfm2fJHfHIrfVi0FSp6Fs 77a4ue312cozn/674fP5i/BhbcPDfEzBN6V/nyz+Ub5mz+ovtypa1+zRnTu3qfWM0u3t6uGz y34+KNzhuuf4XF7JeJdZE0uslrtPr4vVyOJQXPlYIWDJge1KLMUZiYZazEXFiQAlWcI2YAIA AA== X-MTR: 20000000000000000@CPGS Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This simplifies the code a bit and removes a hard coded IO memory region size. Signed-off-by: Sylwester Nawrocki --- sound/soc/samsung/pcm.c | 60 +++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index c484985..d50a637 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c @@ -499,13 +499,6 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) pcm_pdata = pdev->dev.platform_data; - /* Check for availability of necessary resource */ - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem_res) { - dev_err(&pdev->dev, "Unable to get register resource\n"); - return -ENXIO; - } - if (pcm_pdata && pcm_pdata->cfg_gpio && pcm_pdata->cfg_gpio(pdev)) { dev_err(&pdev->dev, "Unable to configure gpio\n"); return -EINVAL; @@ -519,36 +512,26 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) /* Default is 128fs */ pcm->sclk_per_fs = 128; + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + pcm->regs = devm_ioremap_resource(&pdev->dev, mem_res); + if (IS_ERR(pcm->regs)) + return PTR_ERR(pcm->regs); + pcm->cclk = devm_clk_get(&pdev->dev, "audio-bus"); if (IS_ERR(pcm->cclk)) { - dev_err(&pdev->dev, "failed to get audio-bus\n"); - ret = PTR_ERR(pcm->cclk); - goto err1; + dev_err(&pdev->dev, "failed to get audio-bus clock\n"); + return PTR_ERR(pcm->cclk); } clk_prepare_enable(pcm->cclk); /* record our pcm structure for later use in the callbacks */ dev_set_drvdata(&pdev->dev, pcm); - if (!request_mem_region(mem_res->start, - resource_size(mem_res), "samsung-pcm")) { - dev_err(&pdev->dev, "Unable to request register region\n"); - ret = -EBUSY; - goto err2; - } - - pcm->regs = ioremap(mem_res->start, 0x100); - if (pcm->regs == NULL) { - dev_err(&pdev->dev, "cannot ioremap registers\n"); - ret = -ENXIO; - goto err3; - } - pcm->pclk = devm_clk_get(&pdev->dev, "pcm"); if (IS_ERR(pcm->pclk)) { - dev_err(&pdev->dev, "failed to get pcm_clock\n"); - ret = -ENOENT; - goto err4; + dev_err(&pdev->dev, "failed to get pcm clock\n"); + ret = PTR_ERR(pcm->pclk); + goto err_dis_cclk; } clk_prepare_enable(pcm->pclk); @@ -569,7 +552,7 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) NULL, NULL); if (ret) { dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret); - goto err5; + goto err_dis_pclk; } pm_runtime_enable(&pdev->dev); @@ -578,36 +561,25 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) &s3c_pcm_dai[pdev->id], 1); if (ret != 0) { dev_err(&pdev->dev, "failed to get register DAI: %d\n", ret); - goto err6; + goto err_dis_pm; } return 0; -err6: + +err_dis_pm: pm_runtime_disable(&pdev->dev); -err5: +err_dis_pclk: clk_disable_unprepare(pcm->pclk); -err4: - iounmap(pcm->regs); -err3: - release_mem_region(mem_res->start, resource_size(mem_res)); -err2: +err_dis_cclk: clk_disable_unprepare(pcm->cclk); -err1: return ret; } static int s3c_pcm_dev_remove(struct platform_device *pdev) { struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id]; - struct resource *mem_res; pm_runtime_disable(&pdev->dev); - - iounmap(pcm->regs); - - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(mem_res->start, resource_size(mem_res)); - clk_disable_unprepare(pcm->cclk); clk_disable_unprepare(pcm->pclk);