From patchwork Thu Aug 13 07:29:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 7006441 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7EB3F9F39D for ; Thu, 13 Aug 2015 07:29:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98877206D5 for ; Thu, 13 Aug 2015 07:29:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 59542206C0 for ; Thu, 13 Aug 2015 07:29:53 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6C8DC261A32; Thu, 13 Aug 2015 09:29:50 +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=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DB292260591; Thu, 13 Aug 2015 09:29: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 9E33B260670; Thu, 13 Aug 2015 09:29:36 +0200 (CEST) Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by alsa0.perex.cz (Postfix) with ESMTP id 676F72604A1 for ; Thu, 13 Aug 2015 09:29:29 +0200 (CEST) Received: by pabyb7 with SMTP id yb7so32020127pab.0 for ; Thu, 13 Aug 2015 00:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=8QGJwE9BMPkNh+183fi0c7628HHOxywj8JJGA2njVX0=; b=UA6sof7/zdobQp3+M91xMdspxpsaskwvaHaHVJiEWzXIcmj2UxAgaB39JG84tHg6+u QT2Qf214oZ7o6apadQ5Rer4aqz6buMx+3vqLs7avAUIQBZkmxDjdDxjDIkcqu8+r2C2v ylq0LTCYdd79pk7Bzw5/WSJXzUjB4rJ09/Vpv3RXZgYY3rCb2CpwM7sJYEoRSAJUKk27 xSsS57yqadrnAOfM5UlKb3c453u5yrC80NnAbjPN2tZG7vuNJ3eHFHggV/20xNuUZz5N pKjN6JQhnLAFOo5BNlAqe2zBXbldnqkC4mXWTyJLwBC3d1livF1RosrV+WtCmdxZXHPL X5tg== X-Received: by 10.68.136.68 with SMTP id py4mr3125904pbb.70.1439450968122; Thu, 13 Aug 2015 00:29:28 -0700 (PDT) Received: from vaishali-Ideapad-Z570 ([150.107.241.6]) by smtp.gmail.com with ESMTPSA id mi6sm1468925pdb.1.2015.08.13.00.29.26 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Aug 2015 00:29:27 -0700 (PDT) Date: Thu, 13 Aug 2015 12:59:21 +0530 From: Vaishali Thakkar To: Liam Girdwood Message-ID: <20150813072920.GA17181@localhost> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Alexandre Courbot , alsa-devel@alsa-project.org, Stephen Warren , linux-kernel@vger.kernel.org, Wolfram Sang , Takashi Iwai , Mark Brown , Thierry Reding , linux-tegra@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: tegra: Convert to managed resources 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 Use managed resource functions devm_clk_put and devm_snd_soc_register_component to simplify error handling. To be compatible with the change various gotos are replaced with direct returns, and unneeded labels are dropped. Signed-off-by: Vaishali Thakkar --- sound/soc/tegra/tegra20_spdif.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c index 9141477..f69b2e4 100644 --- a/sound/soc/tegra/tegra20_spdif.c +++ b/sound/soc/tegra/tegra20_spdif.c @@ -273,45 +273,40 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev) GFP_KERNEL); if (!spdif) { dev_err(&pdev->dev, "Can't allocate tegra20_spdif\n"); - ret = -ENOMEM; - goto err; + return -ENOMEM; } dev_set_drvdata(&pdev->dev, spdif); - spdif->clk_spdif_out = clk_get(&pdev->dev, "spdif_out"); + spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out"); if (IS_ERR(spdif->clk_spdif_out)) { pr_err("Can't retrieve spdif clock\n"); ret = PTR_ERR(spdif->clk_spdif_out); - goto err; + return ret; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "No memory resource\n"); - ret = -ENODEV; - goto err_clk_put; + return -ENODEV; } dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!dmareq) { dev_err(&pdev->dev, "No DMA resource\n"); - ret = -ENODEV; - goto err_clk_put; + return -ENODEV; } memregion = devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem), DRV_NAME); if (!memregion) { dev_err(&pdev->dev, "Memory region already claimed\n"); - ret = -EBUSY; - goto err_clk_put; + return -EBUSY; } regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); if (!regs) { dev_err(&pdev->dev, "ioremap failed\n"); - ret = -ENOMEM; - goto err_clk_put; + return -ENOMEM; } spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs, @@ -319,7 +314,7 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev) if (IS_ERR(spdif->regmap)) { dev_err(&pdev->dev, "regmap init failed\n"); ret = PTR_ERR(spdif->regmap); - goto err_clk_put; + return ret; } spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; @@ -334,8 +329,9 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev) goto err_pm_disable; } - ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component, - &tegra20_spdif_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &tegra20_spdif_component, + &tegra20_spdif_dai, 1); if (ret) { dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); ret = -ENOMEM; @@ -345,21 +341,17 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev) ret = tegra_pcm_platform_register(&pdev->dev); if (ret) { dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); - goto err_unregister_component; + return ret; } return 0; -err_unregister_component: - snd_soc_unregister_component(&pdev->dev); err_suspend: if (!pm_runtime_status_suspended(&pdev->dev)) tegra20_spdif_runtime_suspend(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); -err_clk_put: - clk_put(spdif->clk_spdif_out); -err: + return ret; } @@ -372,9 +364,6 @@ static int tegra20_spdif_platform_remove(struct platform_device *pdev) tegra20_spdif_runtime_suspend(&pdev->dev); tegra_pcm_platform_unregister(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - - clk_put(spdif->clk_spdif_out); return 0; }