From patchwork Fri Mar 9 17:48:54 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: 10271427 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 9AF0C603B5 for ; Fri, 9 Mar 2018 17:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 874E929D59 for ; Fri, 9 Mar 2018 17:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C09029D7D; Fri, 9 Mar 2018 17:50:19 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no 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 CD51229D59 for ; Fri, 9 Mar 2018 17:50:18 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 50AB1267617; Fri, 9 Mar 2018 18:50:11 +0100 (CET) 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 BB53026760F; Fri, 9 Mar 2018 18:50:07 +0100 (CET) Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by alsa0.perex.cz (Postfix) with ESMTP id 9B8FB267442 for ; Fri, 9 Mar 2018 18:50:05 +0100 (CET) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180309175004epoutp011aaba486686713818aaf74549dbb9e32~aUdYgIB-q0139201392epoutp01-; Fri, 9 Mar 2018 17:50:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180309175004epoutp011aaba486686713818aaf74549dbb9e32~aUdYgIB-q0139201392epoutp01- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520617804; bh=vMP9bxYisC//H6UW5/OgH6F53fAWCuDyNEBG3d1XGF0=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=GjKBm+GlmPra0GlIZpRZU8IX4RP7R4yjUpDwLRtZ6Ule+H2QNkfLbfEsDCAFtyIw0 dv3678uu/DGe3AmzpvXVJkzcNe6nFYp14TSFeUW8lqEn67/w9znMI6blssitmvlHVO B5FHSPkW2qefaaVQN/9Btie7AgoP7YR8cywUSKPU= Received: from epsmges2p1.samsung.com (unknown [182.195.42.69]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20180309175003epcas2p487b56fedd2e31b6367da0664c5a027bc~aUdXodGkt2464524645epcas2p44; Fri, 9 Mar 2018 17:50:03 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 7B.16.04131.B49C2AA5; Sat, 10 Mar 2018 02:50:03 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180309175002epcas2p3236ef0496e8848f4a802440b22d6f54c~aUdXQuLnf0909409094epcas2p3r; Fri, 9 Mar 2018 17:50:02 +0000 (GMT) X-AuditID: b6c32a45-403ff70000001023-0a-5aa2c94bb552 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 36.DD.03890.A49C2AA5; Sat, 10 Mar 2018 02:50:02 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5C0033645R9230@mmp2.samsung.com>; Sat, 10 Mar 2018 02:50:02 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Date: Fri, 09 Mar 2018 18:48:54 +0100 Message-id: <20180309174858.24017-3-s.nawrocki@samsung.com> X-Mailer: git-send-email 2.14.2 In-reply-to: <20180309174858.24017-1-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCIsWRmVeSWpSXmKPExsWy7bCmma73yUVRBks6BCyuXDzEZLFxxnpW i6kPn7BZzD9yjtVi4bTljBbnz29gt/h2pYPJYsb5fUwWa4/cZbdo3XuE3eLwm3ZWi4srvjA5 8Hhs+NzE5rFz1l12j02rOtk83u+7yubRt2UVo8fnTXIBbFFcNimpOZllqUX6dglcGQ3/bzAW nBCr2HfkN1MD4zWhLkZODgkBE4n7f44zdjFycQgJ7GCUuPn2FxuE851RYuKivWwwVRv3nGaF SGxglFi8rYcFwvnFKPHh9kMWkCo2AUOJ3qN9jCC2iICYxO05ncwgRcwCq5gkVt1fCzZKWCBE 4nDbDiYQm0VAVWJO03OwOK+AtcSKL1OZINbJS7xfcB9sEKeAjURvy0OwAyUE9rBJzJqygB2i yEVi1u0FrBC2sMSr41ug4tISz1ZtZISwqyU627rYIZpbGCX+TLsE9ZC1xOHjF8GamQX4JDoO /wUq4gCK80p0tEFDxkOi49EeqDmOEhNu/YYGTD+jxPJV35knMEotYGRYxSiWWlCcm55abFRg qFecmFtcmpeul5yfu4kRHNdarjsYZ5zzOcQowMGoxMO7Y+qiKCHWxLLiytxDjBIczEoivO9r gEK8KYmVValF+fFFpTmpxYcYpTlYlMR52wJcooQE0hNLUrNTUwtSi2CyTBycUg2MG2pvvbEo Pe0TG3JXhuUPk+srHsZm5faog1t3Tp4oyK92yCVgU+Dyefu2VDpkbDdeKr7dqclQec6TUt+Y +6/jZGSqjxzm2neTeZOQhvaKtS7bVrwVPb3vqk3F3pz7jyXfXRUUmGy1gOF3J5u738Lby7cf rHRc8mXWlNhNqSkaWebLMpYLTH3xWYmlOCPRUIu5qDgRANKT5RLnAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJLMWRmVeSWpSXmKPExsVy+t9jQV2vk4uiDCYeNbW4cvEQk8XGGetZ LaY+fMJmMf/IOVaLhdOWM1qcP7+B3eLblQ4mixnn9zFZrD1yl92ide8RdovDb9pZLS6u+MLk wOOx4XMTm8fOWXfZPTat6mTzeL/vKptH35ZVjB6fN8kFsEVx2aSk5mSWpRbp2yVwZTT8v8FY cEKsYt+R30wNjNeEuhg5OSQETCQ27jnN2sXIxSEksI5RYvrBpewgCSGBX4wSTd+sQWw2AUOJ 3qN9jCC2iICYxO05ncwgDcwCq5gkGiY+YQVJCAuESBxu28EEYrMIqErMaXrOBmLzClhLrPgy lQlim7zE+wX3wQZxCthI9LY8BLI5gJZZS2w7Fz2BkWcBI8MqRsnUguLc9NxiowKjvNRyveLE 3OLSvHS95PzcTYzAANx2WKt/B+PjJfGHGAU4GJV4eAVmLIoSYk0sK67MPcQowcGsJML7vgYo xJuSWFmVWpQfX1Sak1p8iFGag0VJnJc//1ikkEB6YklqdmpqQWoRTJaJg1OqgVE2SVNkkd98 gY7FN6eI/3w7WeqC852//ntPvtq7YvGFk0HC2nyHH0d7bfggJv19+7W/1m5Cyz6VeGmd1yuY 9f3GvajVjAXbWE/Mi3LRcYvd1PhY4MGWR566S/+o8hzfElAU8LxIafrWZoXo1ZOc90fqVPBF LP9fVn6ZVzDYofbROaPzc/o5bMuVWIozEg21mIuKEwGrYzqtPAIAAA== X-CMS-MailID: 20180309175002epcas2p3236ef0496e8848f4a802440b22d6f54c X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180309175002epcas2p3236ef0496e8848f4a802440b22d6f54c X-RootMTR: 20180309175002epcas2p3236ef0496e8848f4a802440b22d6f54c References: <20180309174858.24017-1-s.nawrocki@samsung.com> Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, b.zolnierkie@samsung.com, sbkim73@samsung.com, lgirdwood@gmail.com, krzk@kernel.org, javierm@redhat.com, robh+dt@kernel.org, Sylwester Nawrocki , m.szyprowski@samsung.com Subject: [alsa-devel] [PATCH v2 3/7] ASoC: Add snd_soc_of_put_dai_link_codecs() helper function 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 The code for dereferencing device nodes in the 'codecs' array is moved to a separate function so we can avoid open coding that in drivers. Signed-off-by: Sylwester Nawrocki --- Changes since v1: - none. --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) -- 2.14.2 diff --git a/include/sound/soc.h b/include/sound/soc.h index 747fd583b9dc..4a387f0b3d56 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1807,6 +1807,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 96c44f6576c9..a1f86e85bff9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4397,6 +4397,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 @@ -4406,7 +4426,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 */ @@ -4454,14 +4475,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;