From patchwork Wed Mar 7 17:00:37 2018 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: 10264489 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 A53A2602C8 for ; Wed, 7 Mar 2018 17:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94D7829760 for ; Wed, 7 Mar 2018 17:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88A0329755; Wed, 7 Mar 2018 17:01:00 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 7779129736 for ; Wed, 7 Mar 2018 17:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933655AbeCGRA6 (ORCPT ); Wed, 7 Mar 2018 12:00:58 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:14453 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933487AbeCGRA5 (ORCPT ); Wed, 7 Mar 2018 12:00:57 -0500 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180307170056epoutp03d8220edd17c61ff371b506bdd6a638cf~Zsf6QY8CQ0691206912epoutp03i; Wed, 7 Mar 2018 17:00:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180307170056epoutp03d8220edd17c61ff371b506bdd6a638cf~Zsf6QY8CQ0691206912epoutp03i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520442056; bh=MSvezCQqaNH6rAfC8UA7YT1j/8IJCmBO6D4KWUeQKqM=; h=From:To:Cc:Subject:Date:References:From; b=A5FPrUX+3pIunYox8QUUalkBXHJ70nuNFBbEAuxzXLystkRIea5dLE1w0TzbyQHL4 kAqv95Ks8T4REZKIDa1E5OekTJdMYEoQZhlLM7/wQRGumYuQQgg0PgT3KUuz6KWZBY ZHn2qbxj380C4r1Ieijd1FeDwZByqKlqMzUuQcoQ= Received: from epsmges1p4.samsung.com (unknown [182.195.42.56]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20180307170055epcas1p1b61667cc75fc226746bbc25527af2bbb~Zsf5v18N22961129611epcas1p1b; Wed, 7 Mar 2018 17:00:55 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 80.C0.04180.5CA10AA5; Thu, 8 Mar 2018 02:00:53 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180307170053epcas1p4e9ed540f3f3ab235d760ec73ad3ea141~Zsf3ogmEh0847108471epcas1p4p; Wed, 7 Mar 2018 17:00:53 +0000 (GMT) X-AuditID: b6c32a38-ac3ff70000001054-b6-5aa01ac5c420 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 85.8E.03826.5CA10AA5; Thu, 8 Mar 2018 02:00:53 +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 <0P58009NOCL6PT10@mmp1.samsung.com>; Thu, 08 Mar 2018 02:00:53 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Cc: lgirdwood@gmail.com, alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, b.zolnierkie@samsung.com, m.szyprowski@samsung.com, Sylwester Nawrocki Subject: [PATCH 1/6] ASoC: Add snd_soc_of_put_dai_link_codecs() helper function Date: Wed, 07 Mar 2018 18:00:37 +0100 Message-id: <20180307170037.13846-1-s.nawrocki@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsWy7bCmnu5RqQVRBpuOWFlcuXiIyWLjjPWs FlMfPmGz+Halg8lixvl9TBZrj9xltzj8pp3Vgd1jw+cmNo+ds+6ye2xa1cnm0bdlFaPH501y AaxRXDYpqTmZZalF+nYJXBlPl39kLFghVtF94gRbA+MBoS5GTg4JAROJ07fvs4PYQgI7GCXW TODqYuQCsr8zSjxfdZ8VpujLiZ2MEIndjBIzL7xmhnB+MUr8/bQfrIpNwFCi92gfI4gtIiAm cXtOJ1gRs8AeRomrzeuYQRLCAoESbzd3gRWxCKhKzNy7EWw3r4C1xIQr3xkh1slLvF9wH2yd hMBbVomH008wQyRcJB7NfAd1k7DEq+NbgJo5gGxpiUtHbSHC1RKdbV3sEL0tjBJ/pl1ig0hY Sxw+fhGsl1mAT+Ld1x5WiF5eiY42aFh4SCzfPxNqlaPEy/dHmSHhEiux4ckLtgmMkgsYGVYx iqUWFOempxYbFpjoFSfmFpfmpesl5+duYgRHn5bFDsY953wOMQpwMCrx8B74OT9KiDWxrLgy 9xCjBAezkgjvkz9AId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwBAS5RQgLpiSWp2ampBalFMFkm Dk4pYJTNvZYvwG7C8j7d/OXuzN+fmu8pLlqepCjp9Svh690PDyps92zZYcihWHhz5uYVEyPe afeUxkR66SRfq9NawOoUe/rBkzKJKNu42V+/CMqutzu3xrtlkUKw0trJTJVvUipK5oYob5v0 6uof6/13Fmb86VgV8jkqbs2EJpuAdkXG/rk7ruxmeqjEUpyRaKjFXFScCAAi7nLBugIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKJMWRmVeSWpSXmKPExsVy+t9jAd2jUguiDFZP4LG4cvEQk8XGGetZ LaY+fMJm8e1KB5PFjPP7mCzWHrnLbnH4TTurA7vHhs9NbB47Z91l99i0qpPNo2/LKkaPz5vk AlijuGxSUnMyy1KL9O0SuDKeLv/IWLBCrKL7xAm2BsYDQl2MnBwSAiYSX07sZOxi5OIQEtjJ KPHv9Doo5xejxNynO5lAqtgEDCV6j/YxgtgiAmISt+d0MoMUMQvsYZTo39HODpIQFvCXOPPs LpjNIqAqMXPvRjCbV8BaYsKV74wQ6+Ql3i+4zziBkWsBI8MqRsnUguLc9NxiowLDvNRyveLE 3OLSvHS95PzcTYzAwNh2WKtvB+P9JfGHGAU4GJV4eCX+zI8SYk0sK67MPcQowcGsJML7BCTE m5JYWZValB9fVJqTWnyIUZqDRUmc93besUghgfTEktTs1NSC1CKYLBMHp1QD4+IQnwnBlx6H atzctSZZ1vHg4gYT/s5nBUrzX99nN/N8sP8J57+3Tod+MSyeIeA7++0cubT5irs6BISDP6V/ 0SidGxf8c4pYxQW5zVK1pzwruNd/s9psYDzD0ifMbLu1/oz9L9rrU3fzV5ZdenmxoffKarcO nQSNz2+S3nbUZB3wO/n0MuvrGiWW4oxEQy3mouJEAHTolQkIAgAA X-CMS-MailID: 20180307170053epcas1p4e9ed540f3f3ab235d760ec73ad3ea141 X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20180307170053epcas1p4e9ed540f3f3ab235d760ec73ad3ea141 X-RootMTR: 20180307170053epcas1p4e9ed540f3f3ab235d760ec73ad3ea141 References: 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 The code for dereferencing device nodes in the 'codecs' array is moved to a separate function so we can avoid repeating the code in drivers. Signed-off-by: Sylwester Nawrocki --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) -- 2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/sound/soc.h b/include/sound/soc.h index 6a11b0239f74..ad266d7e9553 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1814,6 +1814,7 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, int snd_soc_of_get_dai_link_codecs(struct device *dev, struct device_node *of_node, struct snd_soc_dai_link *dai_link); +void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); int snd_soc_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 39876737c336..e815be0d5863 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4358,6 +4358,26 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, } EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); +/* + * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array + * @dai_link: DAI link + * + * Dereference device nodes acquired by snd_soc_of_get_dai_link_codecs(). + */ +void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link) +{ + struct snd_soc_dai_link_component *component = dai_link->codecs; + int index; + + for (index = 0; index < dai_link->num_codecs; index++, component++) { + if (!component->of_node) + break; + of_node_put(component->of_node); + component->of_node = NULL; + } +} +EXPORT_SYMBOL_GPL(snd_soc_of_put_dai_link_codecs); + /* * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree * @dev: Card device @@ -4367,7 +4387,8 @@ EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); * Builds an array of CODEC DAI components from the DAI link property * 'sound-dai'. * The array is set in the DAI link and the number of DAIs is set accordingly. - * The device nodes in the array (of_node) must be dereferenced by the caller. + * The device nodes in the array (of_node) must be dereferenced by calling + * snd_soc_of_put_dai_link_codecs() on @dai_link. * * Returns 0 for success */ @@ -4415,14 +4436,7 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, } return 0; err: - for (index = 0, component = dai_link->codecs; - index < dai_link->num_codecs; - index++, component++) { - if (!component->of_node) - break; - of_node_put(component->of_node); - component->of_node = NULL; - } + snd_soc_of_put_dai_link_codecs(dai_link); dai_link->codecs = NULL; dai_link->num_codecs = 0; return ret;