From: Rohit kumar <rohitkr@codeaurora.org>
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
Cc: Ajit Pandey <ajitp@codeaurora.org>, Rohit kumar <rohitkr@codeaurora.org>
Subject: [PATCH 1/2] ASoC: soc-core: add snd_soc_of_lookup_component()
Date: Mon, 24 Dec 2018 14:32:12 +0530 [thread overview]
Message-ID: <1545642133-16120-2-git-send-email-rohitkr@codeaurora.org> (raw)
In-Reply-To: <1545642133-16120-1-git-send-email-rohitkr@codeaurora.org>
From: Ajit Pandey <ajitp@codeaurora.org>
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 <ajitp@codeaurora.org>
Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
---
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
*
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
next prev parent reply other threads:[~2018-12-24 9:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-24 9:02 [PATCH 0/2] ASoC: soc-core: add snd_soc_of_lookup_component() Rohit kumar
2018-12-24 9:02 ` Rohit kumar [this message]
2018-12-24 9:02 ` [PATCH 2/2] ASoC: qcom: defer probe if platform dai is not registered Rohit kumar
2019-01-07 18:27 ` Mark Brown
2019-01-09 8:35 ` Rohit Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1545642133-16120-2-git-send-email-rohitkr@codeaurora.org \
--to=rohitkr@codeaurora.org \
--cc=ajitp@codeaurora.org \
--cc=alsa-devel@alsa-project.org \
--cc=asishb@codeaurora.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=plai@codeaurora.org \
--cc=rohkumar@qti.qualcomm.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).