diff mbox

[2/4] ASoC: add of_parse_snd_connection_with_args() for sound-dai/graph connection

Message ID 87y48gvj9i.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Not Applicable
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kuninori Morimoto April 14, 2016, 5:47 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current ASoC card connection is based on "sound-dai" on DT,
but V4L2 connection is using graph base.
This patch adds common function which can detect both connection.

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

Comments

kernel test robot April 14, 2016, 6:17 a.m. UTC | #1
Hi Kuninori,

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.6-rc3 next-20160413]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-graph-base-connection-on-simple-card/20160414-135303
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-x013-201615 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   sound/soc/soc-core.c: In function 'of_parse_snd_soc_connection_with_args':
>> sound/soc/soc-core.c:3848:35: warning: passing argument 1 of 'of_parse_phandle_with_args' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     ret = of_parse_phandle_with_args(np, "sound-dai",
                                      ^
   In file included from sound/soc/soc-core.c:36:0:
   include/linux/of.h:588:19: note: expected 'struct device_node *' but argument is of type 'const struct device_node *'
    static inline int of_parse_phandle_with_args(struct device_node *np,
                      ^

vim +3848 sound/soc/soc-core.c

  3832				*dai_name = pos->dai_drv[id].name;
  3833				if (!*dai_name)
  3834					*dai_name = pos->name;
  3835			}
  3836	
  3837			break;
  3838		}
  3839		mutex_unlock(&client_mutex);
  3840		return ret;
  3841	}
  3842	
  3843	int of_parse_snd_soc_connection_with_args(const struct device_node *np,
  3844						  struct of_phandle_args *out_args)
  3845	{
  3846		int ret;
  3847	
> 3848		ret = of_parse_phandle_with_args(np, "sound-dai",
  3849						 "#sound-dai-cells", 0, out_args);
  3850		if (ret) {
  3851			struct device_node *p_node = NULL;
  3852			struct device_node *ep_node = NULL;
  3853			struct of_endpoint ep;
  3854	
  3855			/* try graph base parse */
  3856			p_node = of_graph_get_remote_port_parent(np);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 02b4a21..17ddc25 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1669,6 +1669,8 @@  unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+int of_parse_snd_soc_connection_with_args(const struct device_node *np,
+					  struct of_phandle_args *out_args);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name);
 int snd_soc_of_get_dai_link_codecs(struct device *dev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d2e62b15..643b244 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -34,6 +34,7 @@ 
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <sound/core.h>
 #include <sound/jack.h>
 #include <sound/pcm.h>
@@ -3839,6 +3840,47 @@  static int snd_soc_get_dai_name(struct of_phandle_args *args,
 	return ret;
 }
 
+int of_parse_snd_soc_connection_with_args(const struct device_node *np,
+					  struct of_phandle_args *out_args)
+{
+	int ret;
+
+	ret = of_parse_phandle_with_args(np, "sound-dai",
+					 "#sound-dai-cells", 0, out_args);
+	if (ret) {
+		struct device_node *p_node = NULL;
+		struct device_node *ep_node = NULL;
+		struct of_endpoint ep;
+
+		/* try graph base parse */
+		p_node = of_graph_get_remote_port_parent(np);
+		if (!p_node)
+			return -EINVAL;
+
+		ep_node = of_graph_get_remote_port(np);
+		if (!p_node) {
+			ret = -EINVAL;
+			goto graph_err_parent;
+		}
+
+		ret = of_graph_parse_endpoint(ep_node, &ep);
+		if (ret < 0)
+			goto graph_err_endpoint;
+
+		out_args->np		= p_node;
+		out_args->args_count	= (1 != of_graph_get_endpoint_count(p_node));
+		out_args->args[0]	= ep.port;
+
+graph_err_endpoint:
+		of_node_put(ep_node);
+graph_err_parent:
+		of_node_put(p_node);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(of_parse_snd_soc_connection_with_args);
+
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name)
 {