From patchwork Thu Jul 21 18:03:49 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: 9242173 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 EAD3D60756 for ; Thu, 21 Jul 2016 18:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEFE120008 for ; Thu, 21 Jul 2016 18:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1EF427D85; Thu, 21 Jul 2016 18:05:11 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFBF120008 for ; Thu, 21 Jul 2016 18:05:10 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 81E97266663; Thu, 21 Jul 2016 20:05:09 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 631AD265D12; Thu, 21 Jul 2016 20:04:16 +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 A0CBF265D3D; Thu, 21 Jul 2016 20:04:15 +0200 (CEST) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by alsa0.perex.cz (Postfix) with ESMTP id 9B68B2654B2 for ; Thu, 21 Jul 2016 20:04:08 +0200 (CEST) Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OAO00LG6FG4QU30@mailout2.samsung.com> for alsa-devel@alsa-project.org; Fri, 22 Jul 2016 03:04:07 +0900 (KST) X-AuditID: cbfee61a-f79106d000000835-04-57910e97dc69 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id AD.4B.02101.79E01975; Fri, 22 Jul 2016 03:04:07 +0900 (KST) Received: from AMDC1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OAO008E6FIH7S40@mmp1.samsung.com>; Fri, 22 Jul 2016 03:04:06 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Date: Thu, 21 Jul 2016 20:03:49 +0200 Message-id: <1469124230-8583-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1469124230-8583-1-git-send-email-s.nawrocki@samsung.com> References: <1469124230-8583-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e+xgO50vonhBj2PpSyuXDzEZLFxxnpW i6kPn7BZvH5haDHj/D4mi8Nv2lkd2Dw2fG5i89i0qpPNo2/LKkaPz5vkAliiuGxSUnMyy1KL 9O0SuDJm3NAtmMRXcXtiJ1MD4wvuLkZODgkBE4nFJw4yQdhiEhfurWfrYuTiEBJYyihxZFcb E4Tzi1Fi9qWp7CBVbAKGEr1H+xhBbBGgjttzOplBipgFljFK7Dr0lBkkISzgL/Ft9kmgIg4O FgFViX8HvEDCvAKuEvvaTrJDbJOTOHlsMiuIzSngJvHl+FU2EFsIqKZ39nXWCYy8CxgZVjFK pBYkFxQnpeca5qWW6xUn5haX5qXrJefnbmIEB9EzqR2MB3e5H2IU4GBU4uG98GZCuBBrYllx Ze4hRgkOZiUR3kDeieFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeR//XxcmJJCeWJKanZpakFoE k2Xi4JRqYNxUVHb0if8hwT36EXbrD7qG/D5SUe76tYbVTfM7r1jQzBtr38XURx/p3780qbA0 3EojT5jz+4ykpbpHTJLkutybVsve/2GZVH0u1kphSXP07X+NS2vOct/SsZJ4f1xPfO3UsqcX LrXmH3OQXRa35vzNW0v6lFImcKQoT7Mpl592yPxySXVfsRJLcUaioRZzUXEiACibKuceAgAA Cc: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, k.kozlowski@samsung.com, Sylwester Nawrocki , b.zolnierkie@samsung.com Subject: [alsa-devel] [PATCH 1/2] ASoC: samsung: Fix error paths in the I2S driver's probe() 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure they secondary DAI device is freed properly when asoc_dma_platform registration fails. This change is needed for proper deferred probe support and will help preventing situations when the CPU DAI's initialization completes without required DMA resources. Signed-off-by: Sylwester Nawrocki --- sound/soc/samsung/i2s.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 27ca116..2bb3550 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1107,6 +1107,11 @@ static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) return i2s; } +static void i2s_free_sec_dai(struct i2s_dai *i2s) +{ + platform_device_del(i2s->pdev); +} + #ifdef CONFIG_PM static int i2s_runtime_suspend(struct device *dev) { @@ -1340,17 +1345,27 @@ static int samsung_i2s_probe(struct platform_device *pdev) return -EINVAL; } - devm_snd_soc_register_component(&pri_dai->pdev->dev, + ret = devm_snd_soc_register_component(&pri_dai->pdev->dev, &samsung_i2s_component, &pri_dai->i2s_dai_drv, 1); + if (ret < 0) + goto err_free_dai; + + ret = samsung_asoc_dma_platform_register(&pdev->dev, pri_dai->filter); + if (ret < 0) + goto err_free_dai; pm_runtime_enable(&pdev->dev); - ret = samsung_asoc_dma_platform_register(&pdev->dev, pri_dai->filter); - if (ret != 0) - return ret; + ret = i2s_register_clock_provider(pdev); + if (!ret) + return 0; - return i2s_register_clock_provider(pdev); + pm_runtime_disable(&pdev->dev); +err_free_dai: + if (sec_dai) + i2s_free_sec_dai(sec_dai); + return ret; } static int samsung_i2s_remove(struct platform_device *pdev)