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: 9242169 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 1FFA560756 for ; Thu, 21 Jul 2016 18:04:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 156B326B4A for ; Thu, 21 Jul 2016 18:04:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09C5E27C39; Thu, 21 Jul 2016 18:04: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=-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 8C22226B4A for ; Thu, 21 Jul 2016 18:04:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751423AbcGUSEJ (ORCPT ); Thu, 21 Jul 2016 14:04:09 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:42873 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750884AbcGUSEI (ORCPT ); Thu, 21 Jul 2016 14:04:08 -0400 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 linux-samsung-soc@vger.kernel.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 Cc: alsa-devel@alsa-project.org, k.kozlowski@samsung.com, b.zolnierkie@samsung.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH 1/2] ASoC: samsung: Fix error paths in the I2S driver's probe() 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 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 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)