[01/15] ASoC: soc-core: support snd_soc_dai_link_component for codec_conf
diff mbox series

Message ID 87o8wee4hf.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series
  • ASoC: soc-core cleanup step7
Related show

Commit Message

Kuninori Morimoto Dec. 12, 2019, 1:07 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

To find codec_conf component, it is using dev_name, of_node.
But, we already has this kind of finding component method by
snd_soc_dai_link_component, and snd_soc_is_matching_component().
We shouldn't have duplicate implementation to do same things.
This patch adds snd_soc_dai_link_component support to find
codec_conf component.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  3 +++
 sound/soc/soc-core.c | 18 +++++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

Comments

Pierre-Louis Bossart Dec. 12, 2019, 2:28 a.m. UTC | #1
On 12/11/19 7:07 PM, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> To find codec_conf component, it is using dev_name, of_node.
> But, we already has this kind of finding component method by
> snd_soc_dai_link_component, and snd_soc_is_matching_component().
> We shouldn't have duplicate implementation to do same things.
> This patch adds snd_soc_dai_link_component support to find
> codec_conf component.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Thanks Morimoto-san, this looks good to me, but I couldn't resist a 
small nit-pick below.

> ---
>   include/sound/soc.h  |  3 +++
>   sound/soc/soc-core.c | 18 +++++++++++-------
>   2 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 82e6523..dab1212 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -949,6 +949,7 @@ struct snd_soc_dai_link {
>   #define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
>   #define COMP_PLATFORM(_name)		{ .name = _name }
>   #define COMP_AUX(_name)			{ .name = _name }
> +#define COMP_CODEC_CNF(_name)		{ .name = _name }

COMP_CODEC_CONF() ?

CNF is not an acronym/concept we use anywhere else, whereas codec_conf 
is pretty much the default for variable naming.

> -	codec_conf->of_node	= of_node;
> +	codec_conf->dlc.of_node	= of_node;
>   	codec_conf->name_prefix	= str;
Kuninori Morimoto Dec. 12, 2019, 2:41 a.m. UTC | #2
Hi Pierre-Louis

Thank you for your feedback

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > To find codec_conf component, it is using dev_name, of_node.
> > But, we already has this kind of finding component method by
> > snd_soc_dai_link_component, and snd_soc_is_matching_component().
> > We shouldn't have duplicate implementation to do same things.
> > This patch adds snd_soc_dai_link_component support to find
> > codec_conf component.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Thanks Morimoto-san, this looks good to me, but I couldn't resist a
> small nit-pick below.
> 
> > ---
> >   include/sound/soc.h  |  3 +++
> >   sound/soc/soc-core.c | 18 +++++++++++-------
> >   2 files changed, 14 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/sound/soc.h b/include/sound/soc.h
> > index 82e6523..dab1212 100644
> > --- a/include/sound/soc.h
> > +++ b/include/sound/soc.h
> > @@ -949,6 +949,7 @@ struct snd_soc_dai_link {
> >   #define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
> >   #define COMP_PLATFORM(_name)		{ .name = _name }
> >   #define COMP_AUX(_name)			{ .name = _name }
> > +#define COMP_CODEC_CNF(_name)		{ .name = _name }
> 
> COMP_CODEC_CONF() ?
> 
> CNF is not an acronym/concept we use anywhere else, whereas codec_conf
> is pretty much the default for variable naming.

I see.
I will fixup and post v2 tomorrow.

Thank you for your help !!
Best regards
---
Kuninori Morimoto

Patch
diff mbox series

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 82e6523..dab1212 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -949,6 +949,7 @@  struct snd_soc_dai_link {
 #define COMP_CODEC(_name, _dai)		{ .name = _name, .dai_name = _dai, }
 #define COMP_PLATFORM(_name)		{ .name = _name }
 #define COMP_AUX(_name)			{ .name = _name }
+#define COMP_CODEC_CNF(_name)		{ .name = _name }
 #define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
 
 extern struct snd_soc_dai_link_component null_dailink_component[0];
@@ -962,6 +963,8 @@  struct snd_soc_codec_conf {
 	const char *dev_name;
 	struct device_node *of_node;
 
+	struct snd_soc_dai_link_component dlc;
+
 	/*
 	 * optional map of kcontrol, widget and path name prefixes that are
 	 * associated per device
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ee77db2..411b83b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1185,12 +1185,16 @@  static void soc_set_name_prefix(struct snd_soc_card *card,
 	for (i = 0; i < card->num_configs; i++) {
 		struct snd_soc_codec_conf *map = &card->codec_conf[i];
 
-		if (map->of_node && of_node != map->of_node)
-			continue;
-		if (map->dev_name && strcmp(component->name, map->dev_name))
-			continue;
-		component->name_prefix = map->name_prefix;
-		return;
+		/* fixme */
+		if (map->dev_name)
+			map->dlc.name = map->dev_name;
+		if (map->of_node)
+			map->dlc.of_node = map->of_node;
+
+		if (snd_soc_is_matching_component(&map->dlc, component)) {
+			component->name_prefix = map->name_prefix;
+			return;
+		}
 	}
 
 	/*
@@ -2915,7 +2919,7 @@  void snd_soc_of_parse_node_prefix(struct device_node *np,
 		return;
 	}
 
-	codec_conf->of_node	= of_node;
+	codec_conf->dlc.of_node	= of_node;
 	codec_conf->name_prefix	= str;
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_node_prefix);