ASoC: soc-core: add soc_component_to_node()

Many function are getting device_node from component
with caring its parent component.
This patch adds new soc_component_to_node() and share
same code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2019-05-13 16:06:59 +09:00 committed by Mark Brown
parent e2b30edfb9
commit c083444061
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 18 additions and 21 deletions

View File

@ -738,6 +738,18 @@ EXPORT_SYMBOL_GPL(snd_soc_resume);
static const struct snd_soc_dai_ops null_dai_ops = {
};
static struct device_node
*soc_component_to_node(struct snd_soc_component *component)
{
struct device_node *of_node;
of_node = component->dev->of_node;
if (!of_node && component->dev->parent)
of_node = component->dev->parent->of_node;
return of_node;
}
static struct snd_soc_component *soc_find_component(
const struct device_node *of_node, const char *name)
{
@ -748,9 +760,7 @@ static struct snd_soc_component *soc_find_component(
for_each_component(component) {
if (of_node) {
component_of_node = component->dev->of_node;
if (!component_of_node && component->dev->parent)
component_of_node = component->dev->parent->of_node;
component_of_node = soc_component_to_node(component);
if (component_of_node == of_node)
return component;
@ -768,9 +778,7 @@ static int snd_soc_is_matching_component(
{
struct device_node *component_of_node;
component_of_node = component->dev->of_node;
if (!component_of_node && component->dev->parent)
component_of_node = component->dev->parent->of_node;
component_of_node = soc_component_to_node(component);
if (dlc->of_node && component_of_node != dlc->of_node)
return 0;
@ -1317,13 +1325,10 @@ EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link);
static void soc_set_of_name_prefix(struct snd_soc_component *component)
{
struct device_node *component_of_node = component->dev->of_node;
struct device_node *component_of_node = soc_component_to_node(component);
const char *str;
int ret;
if (!component_of_node && component->dev->parent)
component_of_node = component->dev->parent->of_node;
ret = of_property_read_string(component_of_node, "sound-name-prefix",
&str);
if (!ret)
@ -1337,10 +1342,7 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
for (i = 0; i < card->num_configs && card->codec_conf; i++) {
struct snd_soc_codec_conf *map = &card->codec_conf[i];
struct device_node *component_of_node = component->dev->of_node;
if (!component_of_node && component->dev->parent)
component_of_node = component->dev->parent->of_node;
struct device_node *component_of_node = soc_component_to_node(component);
if (map->of_node && component_of_node != map->of_node)
continue;
@ -3764,10 +3766,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
ret = -ENOTSUPP;
mutex_lock(&client_mutex);
for_each_component(pos) {
struct device_node *component_of_node = pos->dev->of_node;
if (!component_of_node && pos->dev->parent)
component_of_node = pos->dev->parent->of_node;
struct device_node *component_of_node = soc_component_to_node(pos);
if (component_of_node != node)
continue;
@ -3794,9 +3793,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,
mutex_lock(&client_mutex);
for_each_component(pos) {
component_of_node = pos->dev->of_node;
if (!component_of_node && pos->dev->parent)
component_of_node = pos->dev->parent->of_node;
component_of_node = soc_component_to_node(pos);
if (component_of_node != args->np)
continue;