From patchwork Mon Dec 24 09:02:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Kumar X-Patchwork-Id: 10742159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1B591800 for ; Mon, 24 Dec 2018 09:38:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA5228A8E for ; Mon, 24 Dec 2018 09:38:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D430A28E8F; Mon, 24 Dec 2018 09:38:12 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 7EFCD28A8E for ; Mon, 24 Dec 2018 09:38:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 1CC3B267AC5; Mon, 24 Dec 2018 10:38:05 +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 80906267A6C; Mon, 24 Dec 2018 10:38:00 +0100 (CET) Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by alsa0.perex.cz (Postfix) with ESMTP id 36D432679F3 for ; Mon, 24 Dec 2018 10:37:57 +0100 (CET) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4EF43608D2; Mon, 24 Dec 2018 09:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1545642153; bh=sqv/7b07JMffuJ9eCQnJP3l5cw7GMu9D8JvslewsM3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=htnFEDbjaLhGh7wgqUuMzjbYkf12npMTTlYvmsWBC7jDAMXYvzI0yHNH+KrXTHTTw Fk70QnXd3HCEr6UHt04W7Fx89jJhDjeWIYcXZiXVgxii29RFUKaCS6ccMxp+gA+USL Y9hwZWv5dLul3Rkh5Q3Hfm9I9czajVGYD2bomLWs= Received: from rohkumar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rohitkr@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 01E95608D4; Mon, 24 Dec 2018 09:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1545642152; bh=sqv/7b07JMffuJ9eCQnJP3l5cw7GMu9D8JvslewsM3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NNqUO6r+O6jJKsPbw1FBb95GeOv6KKjfZcYTzrkRiNOyX0Pa1nDuWLWChz4xUiwQa qCRzS6jR3AqmP54VkHFAoDKGM2yKDu+O6vEz+VUdJt4tA58vg3zPFh5b3Fuj2qc9hf 4IZtxdWU9wwd3LHg98cyqhOfosoz91g07VqhQyqo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 01E95608D4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rohitkr@codeaurora.org From: Rohit kumar To: plai@codeaurora.org, bgoswami@codeaurora.org, asishb@codeaurora.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, rohkumar@qti.qualcomm.com, srinivas.kandagatla@linaro.org Date: Mon, 24 Dec 2018 14:32:12 +0530 Message-Id: <1545642133-16120-2-git-send-email-rohitkr@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1545642133-16120-1-git-send-email-rohitkr@codeaurora.org> References: <1545642133-16120-1-git-send-email-rohitkr@codeaurora.org> Cc: Rohit kumar , Ajit Pandey Subject: [alsa-devel] [PATCH 1/2] ASoC: soc-core: add snd_soc_of_lookup_component() 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 From: Ajit Pandey Soundcard should be registered after all components are registered. Add snd_soc_of_lookup_component() to get component info from device_node. This can be used by machine driver to make sure that card components are registered before calling snd_soc_register_card(). Signed-off-by: Ajit Pandey Signed-off-by: Rohit kumar --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 8ec1de8..dc251fc 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1502,6 +1502,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args, const char **dai_name); int snd_soc_of_get_dai_name(struct device_node *of_node, const char **dai_name); +struct snd_soc_component *snd_soc_of_lookup_component(struct device_node *np); int snd_soc_of_get_dai_link_codecs(struct device *dev, struct device_node *of_node, struct snd_soc_dai_link *dai_link); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0462b3e..ab27bc5 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3797,6 +3797,34 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); /* + * snd_soc_of_lookup_component - Lookup component with device node + * @np: device node pointer + * + * This function looks up component based on given of_node + * + * Returns valid component pointer on success and NULL on failure to find one. + */ +struct snd_soc_component *snd_soc_of_lookup_component(struct device_node *np) +{ + struct snd_soc_component *component = NULL; + bool found = false; + + if (!np) + return NULL; + + mutex_lock(&client_mutex); + for_each_component(component) + if (component->dev->of_node == np) { + found = true; + break; + } + mutex_unlock(&client_mutex); + + return found ? component : NULL; +} +EXPORT_SYMBOL_GPL(snd_soc_of_lookup_component); + +/* * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array * @dai_link: DAI link *