diff mbox

[v5,09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()

Message ID 877f7owccz.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kuninori Morimoto Nov. 28, 2016, 2:47 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple-card already has asoc_simple_card_parse_dai(),
but graph base parsing needs graph specific version of it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     | 10 +++++++
 sound/soc/generic/simple-card-utils.c | 53 +++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

Comments

kernel test robot Nov. 28, 2016, 3:41 a.m. UTC | #1
Hi Kuninori,

[auto build test ERROR on robh/for-next]
[also build test ERROR on v4.9-rc7]
[cannot apply to glikely/devicetree/next asoc/for-next next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-OF-graph-base-simple-card/20161128-111639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: i386-randconfig-x002-201648 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   sound/soc/generic/simple-card-utils.c: In function 'asoc_simple_card_parse_card_name':
   sound/soc/generic/simple-card-utils.c:92:8: error: implicit declaration of function 'snd_soc_of_parse_card_name_from_node' [-Werror=implicit-function-declaration]
     ret = snd_soc_of_parse_card_name_from_node(card, node, prop);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/generic/simple-card-utils.c: In function 'asoc_simple_card_parse_graph_dai':
>> sound/soc/generic/simple-card-utils.c:210:9: error: implicit declaration of function 'snd_soc_get_dai_name' [-Werror=implicit-function-declaration]
      ret = snd_soc_get_dai_name(&args, dai_name);
            ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/snd_soc_get_dai_name +210 sound/soc/generic/simple-card-utils.c

    86		char prop[128];
    87		int ret;
    88	
    89		snprintf(prop, sizeof(prop), "%sname", prefix);
    90	
    91		/* Parse the card name from DT */
  > 92		ret = snd_soc_of_parse_card_name_from_node(card, node, prop);
    93		if (ret < 0)
    94			return ret;
    95	
    96		if (!card->name && card->dai_link)
    97			card->name = card->dai_link->name;
    98	
    99		return 0;
   100	}
   101	EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
   102	
   103	int asoc_simple_card_parse_clk(struct device_node *node,
   104				       struct device_node *dai_of_node,
   105				       struct asoc_simple_dai *simple_dai)
   106	{
   107		struct clk *clk;
   108		u32 val;
   109	
   110		/*
   111		 * Parse dai->sysclk come from "clocks = <&xxx>"
   112		 * (if system has common clock)
   113		 *  or "system-clock-frequency = <xxx>"
   114		 *  or device's module clock.
   115		 */
   116		clk = of_clk_get(node, 0);
   117		if (!IS_ERR(clk)) {
   118			simple_dai->sysclk = clk_get_rate(clk);
   119			simple_dai->clk = clk;
   120		} else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
   121			simple_dai->sysclk = val;
   122		} else {
   123			clk = of_clk_get(dai_of_node, 0);
   124			if (!IS_ERR(clk))
   125				simple_dai->sysclk = clk_get_rate(clk);
   126		}
   127	
   128		return 0;
   129	}
   130	EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);
   131	
   132	int asoc_simple_card_parse_dai(struct device_node *node,
   133					    struct device_node **dai_of_node,
   134					    const char **dai_name,
   135					    const char *list_name,
   136					    const char *cells_name,
   137					    int *is_single_link)
   138	{
   139		struct of_phandle_args args;
   140		int ret;
   141	
   142		if (!node)
   143			return 0;
   144	
   145		/*
   146		 * Get node via "sound-dai = <&phandle port>"
   147		 * it will be used as xxx_of_node on soc_bind_dai_link()
   148		 */
   149		ret = of_parse_phandle_with_args(node, list_name, cells_name, 0, &args);
   150		if (ret)
   151			return ret;
   152	
   153		/* Get dai->name */
   154		if (dai_name) {
   155			ret = snd_soc_of_get_dai_name(node, dai_name);
   156			if (ret < 0)
   157				return ret;
   158		}
   159	
   160		*dai_of_node = args.np;
   161	
   162		if (is_single_link)
   163			*is_single_link = !args.args_count;
   164	
   165		return 0;
   166	}
   167	EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
   168	
   169	int asoc_simple_card_parse_graph_dai(struct device_node *ep,
   170					     struct device_node **dai_of_node,
   171					     const char **dai_name)
   172	{
   173		struct device_node *node, *port, *endpoint;
   174		int i, id;
   175	
   176		if (!ep)
   177			return 0;
   178	
   179		/*
   180		 * of_graph_get_port_parent() will call
   181		 * of_node_put(). So, call of_node_get() here
   182		 */
   183		of_node_get(ep);
   184		node = of_graph_get_port_parent(ep);
   185	
   186		i = 0;
   187		id = -1;
   188		for_each_of_port(node, port) {
   189			if (!of_graph_port_type_is_sound(port))
   190				continue;
   191	
   192			for_each_of_endpoint_in_port(port, endpoint) {
   193				if (endpoint == ep)
   194					id = i;
   195				i++;
   196			}
   197		}
   198		if (id < 0)
   199			return -ENODEV;
   200	
   201		/* Get dai->name */
   202		if (dai_name) {
   203			struct of_phandle_args args;
   204			int ret;
   205	
   206			args.np		= node;
   207			args.args[0]	= id;
   208			args.args_count	= (i > 1);
   209	
 > 210			ret = snd_soc_get_dai_name(&args, dai_name);
   211			if (ret < 0)
   212				return ret;
   213		}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Kuninori Morimoto Nov. 28, 2016, 4:10 a.m. UTC | #2
Hi

> [auto build test ERROR on robh/for-next]
> [also build test ERROR on v4.9-rc7]
> [cannot apply to glikely/devicetree/next asoc/for-next next-20161125]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-OF-graph-base-simple-card/20161128-111639
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> config: i386-randconfig-x002-201648 (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 

I didn't indicate, but, this patch-set is based on Mark's this branch

	git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git :: topic/of-graph

Best regards
---
Kuninori Morimoto
diff mbox

Patch

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 09750ac..c223f79 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -60,6 +60,16 @@  int asoc_simple_card_parse_dai(struct device_node *node,
 				  const char *cells_name,
 				  int *is_single_links);
 
+#define asoc_simple_card_parse_graph_cpu(ep, dai_link)			\
+	asoc_simple_card_parse_graph_dai(ep, &dai_link->cpu_of_node,	\
+					 &dai_link->cpu_dai_name)
+#define asoc_simple_card_parse_graph_codec(ep, dai_link)		\
+	asoc_simple_card_parse_graph_dai(ep, &dai_link->codec_of_node,	\
+					 &dai_link->codec_dai_name)
+int asoc_simple_card_parse_graph_dai(struct device_node *ep,
+				     struct device_node **endpoint_np,
+				     const char **dai_name);
+
 int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 			      struct asoc_simple_dai *simple_dai);
 
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 003331e..527944d 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -10,6 +10,7 @@ 
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <sound/simple_card_utils.h>
 
 int asoc_simple_card_parse_daifmt(struct device *dev,
@@ -165,6 +166,58 @@  int asoc_simple_card_parse_dai(struct device_node *node,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
 
+int asoc_simple_card_parse_graph_dai(struct device_node *ep,
+				     struct device_node **dai_of_node,
+				     const char **dai_name)
+{
+	struct device_node *node, *port, *endpoint;
+	int i, id;
+
+	if (!ep)
+		return 0;
+
+	/*
+	 * of_graph_get_port_parent() will call
+	 * of_node_put(). So, call of_node_get() here
+	 */
+	of_node_get(ep);
+	node = of_graph_get_port_parent(ep);
+
+	i = 0;
+	id = -1;
+	for_each_of_port(node, port) {
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		for_each_of_endpoint_in_port(port, endpoint) {
+			if (endpoint == ep)
+				id = i;
+			i++;
+		}
+	}
+	if (id < 0)
+		return -ENODEV;
+
+	/* Get dai->name */
+	if (dai_name) {
+		struct of_phandle_args args;
+		int ret;
+
+		args.np		= node;
+		args.args[0]	= id;
+		args.args_count	= (i > 1);
+
+		ret = snd_soc_get_dai_name(&args, dai_name);
+		if (ret < 0)
+			return ret;
+	}
+
+	*dai_of_node = node;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai);
+
 int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 			      struct asoc_simple_dai *simple_dai)
 {