linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: soc-core: add snd_soc_of_lookup_component()
@ 2018-12-24  9:02 Rohit kumar
  2018-12-24  9:02 ` [PATCH 1/2] " Rohit kumar
  2018-12-24  9:02 ` [PATCH 2/2] ASoC: qcom: defer probe if platform dai is not registered Rohit kumar
  0 siblings, 2 replies; 5+ messages in thread
From: Rohit kumar @ 2018-12-24  9:02 UTC (permalink / raw)
  To: plai, bgoswami, asishb, lgirdwood, broonie, perex, tiwai,
	alsa-devel, linux-kernel, rohkumar, srinivas.kandagatla
  Cc: Rohit kumar

Platform DAI component probe is not called if it is not
present in component list during sound card registration.
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().


Ajit Pandey (2):
  ASoC: soc-core: add snd_soc_of_lookup_component()
  ASoC: qcom: defer probe if platform dai is not registered

 include/sound/soc.h     |  1 +
 sound/soc/qcom/common.c |  9 +++++++++
 sound/soc/soc-core.c    | 28 ++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+)

-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] ASoC: soc-core: add snd_soc_of_lookup_component()
  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
  2018-12-24  9:02 ` [PATCH 2/2] ASoC: qcom: defer probe if platform dai is not registered Rohit kumar
  1 sibling, 0 replies; 5+ messages in thread
From: Rohit kumar @ 2018-12-24  9:02 UTC (permalink / raw)
  To: plai, bgoswami, asishb, lgirdwood, broonie, perex, tiwai,
	alsa-devel, linux-kernel, rohkumar, srinivas.kandagatla
  Cc: Ajit Pandey, Rohit kumar

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.


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] ASoC: qcom: defer probe if platform dai is not registered
  2018-12-24  9:02 [PATCH 0/2] ASoC: soc-core: add snd_soc_of_lookup_component() Rohit kumar
  2018-12-24  9:02 ` [PATCH 1/2] " Rohit kumar
@ 2018-12-24  9:02 ` Rohit kumar
  2019-01-07 18:27   ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Rohit kumar @ 2018-12-24  9:02 UTC (permalink / raw)
  To: plai, bgoswami, asishb, lgirdwood, broonie, perex, tiwai,
	alsa-devel, linux-kernel, rohkumar, srinivas.kandagatla
  Cc: Ajit Pandey, Rohit kumar

From: Ajit Pandey <ajitp@codeaurora.org>

Platform DAI component probe is not called if it is not
present in component list during sound card registration.
Check if component is registered for platform dai before
soundcard registration.

Signed-off-by: Ajit Pandey <ajitp@codeaurora.org>
Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
---
 sound/soc/qcom/common.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 4715527..9e98458 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -11,6 +11,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 	struct device_node *codec = NULL;
 	struct device_node *platform = NULL;
 	struct device_node *cpu = NULL;
+	struct snd_soc_component *component = NULL;
 	struct device *dev = card->dev;
 	struct snd_soc_dai_link *link;
 	struct of_phandle_args args;
@@ -75,6 +76,14 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 				goto err;
 			}
 
+			component = snd_soc_of_lookup_component
+						(link->platform_of_node);
+			if (!component) {
+				ret = -EPROBE_DEFER;
+				dev_err(card->dev, "platform DAI not registered\n");
+				goto err;
+			}
+
 			ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
 			if (ret < 0) {
 				dev_err(card->dev, "codec dai not found\n");
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ASoC: qcom: defer probe if platform dai is not registered
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2019-01-07 18:27 UTC (permalink / raw)
  To: Rohit kumar
  Cc: plai, bgoswami, asishb, lgirdwood, perex, tiwai, alsa-devel,
	linux-kernel, rohkumar, srinivas.kandagatla, Ajit Pandey

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

On Mon, Dec 24, 2018 at 02:32:13PM +0530, Rohit kumar wrote:
> From: Ajit Pandey <ajitp@codeaurora.org>
> 
> Platform DAI component probe is not called if it is not
> present in component list during sound card registration.
> Check if component is registered for platform dai before
> soundcard registration.

Why do we need to do this in the driver, I'd expect this to be something
that we need to do for everything not just this driver so I'd expect it
to be handled in the core?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ASoC: qcom: defer probe if platform dai is not registered
  2019-01-07 18:27   ` Mark Brown
@ 2019-01-09  8:35     ` Rohit Kumar
  0 siblings, 0 replies; 5+ messages in thread
From: Rohit Kumar @ 2019-01-09  8:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: plai, bgoswami, asishb, lgirdwood, perex, tiwai, alsa-devel,
	linux-kernel, rohkumar, srinivas.kandagatla, Ajit Pandey

Thanks Mark for review.

On 1/7/2019 11:57 PM, Mark Brown wrote:
> On Mon, Dec 24, 2018 at 02:32:13PM +0530, Rohit kumar wrote:
>> From: Ajit Pandey <ajitp@codeaurora.org>
>>
>> Platform DAI component probe is not called if it is not
>> present in component list during sound card registration.
>> Check if component is registered for platform dai before
>> soundcard registration.
> Why do we need to do this in the driver, I'd expect this to be something
> that we need to do for everything not just this driver so I'd expect it
> to be handled in the core?
True. Will post generic change which will not need change in machine driver.

-- 
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-09  8:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24  9:02 [PATCH 0/2] ASoC: soc-core: add snd_soc_of_lookup_component() Rohit kumar
2018-12-24  9:02 ` [PATCH 1/2] " Rohit kumar
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

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).