From patchwork Tue Apr 22 11:03:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 4031021 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 49C38BFF02 for ; Tue, 22 Apr 2014 11:05:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 37E6620219 for ; Tue, 22 Apr 2014 11:05:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id AC46D2021F for ; Tue, 22 Apr 2014 11:05:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A4195264F22; Tue, 22 Apr 2014 13:05:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 572D5261B33; Tue, 22 Apr 2014 13:03:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DDC18261B21; Tue, 22 Apr 2014 13:03:36 +0200 (CEST) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by alsa0.perex.cz (Postfix) with ESMTP id A11A4261A92 for ; Tue, 22 Apr 2014 13:03:29 +0200 (CEST) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3MB3PRg016366; Tue, 22 Apr 2014 06:03:25 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3MB3Pdm007233; Tue, 22 Apr 2014 06:03:25 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 22 Apr 2014 06:03:25 -0500 Received: from dflp33.itg.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3MB3GTO026234; Tue, 22 Apr 2014 06:03:23 -0500 From: Peter Ujfalusi To: Mark Brown , Liam Girdwood Date: Tue, 22 Apr 2014 14:03:14 +0300 Message-ID: <1398164594-29169-4-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1398164594-29169-1-git-send-email-peter.ujfalusi@ti.com> References: <1398164594-29169-1-git-send-email-peter.ujfalusi@ti.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, daniel@zonque.org, Jyri Sarha Subject: [alsa-devel] [PATCH 3/3] ASoC: davinci-mcasp: Optimize pm_runtime usage and clean up the init code X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Move the pm_runtime_enable/disable to dai driver probe/remove callbacks from module probe/remove callbacks. With this change we can remove the platform driver's remove function since it became NULL. Signed-off-by: Peter Ujfalusi --- sound/soc/davinci/davinci-mcasp.c | 45 +++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 14058dc6eaf8..c858c9ccf774 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -778,6 +778,8 @@ static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai) { struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); + pm_runtime_enable(mcasp->dev); + if (mcasp->version == MCASP_VERSION_4) { /* Using dmaengine PCM */ dai->playback_dma_data = @@ -793,6 +795,15 @@ static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai) return 0; } +static int davinci_mcasp_dai_remove(struct snd_soc_dai *dai) +{ + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); + + pm_runtime_disable(mcasp->dev); + + return 0; +} + #ifdef CONFIG_PM_SLEEP static int davinci_mcasp_suspend(struct snd_soc_dai *dai) { @@ -847,6 +858,7 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = { { .name = "davinci-mcasp.0", .probe = davinci_mcasp_dai_probe, + .remove = davinci_mcasp_dai_remove, .suspend = davinci_mcasp_suspend, .resume = davinci_mcasp_resume, .playback = { @@ -867,6 +879,7 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = { { .name = "davinci-mcasp.1", .probe = davinci_mcasp_dai_probe, + .remove = davinci_mcasp_dai_remove, .playback = { .channels_min = 1, .channels_max = 384, @@ -1122,19 +1135,10 @@ static int davinci_mcasp_probe(struct platform_device *pdev) return -EBUSY; } - pm_runtime_enable(&pdev->dev); - - ret = pm_runtime_get_sync(&pdev->dev); - if (IS_ERR_VALUE(ret)) { - dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n"); - return ret; - } - mcasp->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); if (!mcasp->base) { dev_err(&pdev->dev, "ioremap failed\n"); - ret = -ENOMEM; - goto err; + return -ENOMEM; } mcasp->op_mode = pdata->op_mode; @@ -1220,7 +1224,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) &davinci_mcasp_dai[pdata->op_mode], 1); if (ret != 0) - goto err; + return ret; switch (mcasp->version) { case MCASP_VERSION_1: @@ -1238,30 +1242,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev) break; } - if (ret) { - dev_err(&pdev->dev, "register PCM failed: %d\n", ret); - goto err; - } - - return 0; - -err: - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); return ret; } -static int davinci_mcasp_remove(struct platform_device *pdev) -{ - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - - return 0; -} - static struct platform_driver davinci_mcasp_driver = { .probe = davinci_mcasp_probe, - .remove = davinci_mcasp_remove, .driver = { .name = "davinci-mcasp", .owner = THIS_MODULE,