ASoC: core: If component doesn't have of_node use parent's node instead
authorJyri Sarha <jsarha@ti.com>
Tue, 26 May 2015 18:59:05 +0000 (21:59 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 2 Jun 2015 20:09:11 +0000 (21:09 +0100)
If an ASoC component device does not have a device tree node, use its
parent's node instead, when looking for a matching DAI based on a
device tree reference.

This allows video device drivers to register a separate child device
for their ASoC side audio functionality.  [And MFDs in general --
broonie]

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 95414a2cec1b6683b2f99c66deeb961e3b6cbe2a..80b7cf5ef69abe0d215c0e628b45880ded700844 100644 (file)
@@ -895,12 +895,17 @@ static struct snd_soc_dai *snd_soc_find_dai(
 {
        struct snd_soc_component *component;
        struct snd_soc_dai *dai;
+       struct device_node *component_of_node;
 
        lockdep_assert_held(&client_mutex);
 
        /* Find CPU DAI from registered DAIs*/
        list_for_each_entry(component, &component_list, list) {
-               if (dlc->of_node && component->dev->of_node != dlc->of_node)
+               component_of_node = component->dev->of_node;
+               if (!component_of_node && component->dev->parent)
+                       component_of_node = component->dev->parent->of_node;
+
+               if (dlc->of_node && component_of_node != dlc->of_node)
                        continue;
                if (dlc->name && strcmp(component->name, dlc->name))
                        continue;
@@ -3480,11 +3485,16 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args,
                                const char **dai_name)
 {
        struct snd_soc_component *pos;
+       struct device_node *component_of_node;
        int ret = -EPROBE_DEFER;
 
        mutex_lock(&client_mutex);
        list_for_each_entry(pos, &component_list, list) {
-               if (pos->dev->of_node != args->np)
+               component_of_node = pos->dev->of_node;
+               if (!component_of_node && pos->dev->parent)
+                       component_of_node = pos->dev->parent->of_node;
+
+               if (component_of_node != args->np)
                        continue;
 
                if (pos->driver->of_xlate_dai_name) {