From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Herring Subject: Re: [PATCH v4 7/9] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() Date: Mon, 20 Mar 2017 15:26:06 -0500 Message-ID: References: <8760jdivfm.wl%kuninori.morimoto.gx@renesas.com> <87vardhgia.wl%kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <87vardhgia.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Kuninori Morimoto Cc: Mark Brown , Linux-ALSA , Simon , Linux-DT List-Id: devicetree@vger.kernel.org On Mon, Mar 13, 2017 at 12:54 AM, Kuninori Morimoto wrote: > From: Kuninori Morimoto > > simple-card already has asoc_simple_card_parse_dai(), > but graph base parsing needs graph specific version of it. > > Signed-off-by: Kuninori Morimoto > --- > v3 -> v4 > > - no change > > include/sound/simple_card_utils.h | 10 ++++++++++ > sound/soc/generic/simple-card-utils.c | 36 +++++++++++++++++++++++++++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h > index af58d23..efab584 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 4dfd9a2..67c3fa4 100644 > --- a/sound/soc/generic/simple-card-utils.c > +++ b/sound/soc/generic/simple-card-utils.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > > int asoc_simple_card_parse_daifmt(struct device *dev, > @@ -174,6 +175,41 @@ 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; > + struct of_phandle_args args; > + int ret; > + > + if (!ep) > + return 0; > + if (!dai_name) > + 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); > + > + /* Get dai->name */ > + args.np = node; > + args.args[0] = snd_soc_get_dai_id(ep); > + args.args_count = (of_graph_get_endpoint_count(node) > 1); This is a bit pointless. It's not the kernel's job to validate the DT. If you don't have a graph, then of_graph_get_port_parent would have already failed. > + > + 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) > { > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html