diff mbox

[11/49] ASoC: simple-card-core: add asoc_simple_card_parse_card_widgets()

Message ID 8760u9rrtl.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kuninori Morimoto May 20, 2016, 9:46 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple-card is supporting widgets.
This patch makes this method simple style standard.

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

Comments

Mark Brown May 30, 2016, 4:23 p.m. UTC | #1
On Fri, May 20, 2016 at 09:46:04AM +0000, Kuninori Morimoto wrote:

> +int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card,
> +					char *prefix)
> +{
> +	struct device_node *np = card->dev->of_node;
> +	char prop[128];
> +	int ret = 0;
> +
> +	snprintf(prop, sizeof(prop), "%swidgets", prefix);
> +
> +	if (of_property_read_bool(np, prop))
> +		ret = snd_soc_of_parse_audio_simple_widgets(card, prop);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_widgets);

This seems like an extremely thin wrapper around existing core
functionality, shouldn't we just be adding the property check into the
core?
Kuninori Morimoto May 31, 2016, 2:05 a.m. UTC | #2
Hi Mark

> > +int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card,
> > +					char *prefix)
> > +{
> > +	struct device_node *np = card->dev->of_node;
> > +	char prop[128];
> > +	int ret = 0;
> > +
> > +	snprintf(prop, sizeof(prop), "%swidgets", prefix);
> > +
> > +	if (of_property_read_bool(np, prop))
> > +		ret = snd_soc_of_parse_audio_simple_widgets(card, prop);
> > +
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_widgets);
> 
> This seems like an extremely thin wrapper around existing core
> functionality, shouldn't we just be adding the property check into the
> core?

OK, will do in v2
Kuninori Morimoto May 31, 2016, 2:19 a.m. UTC | #3
Hi Mark, again

> > > +int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card,
> > > +					char *prefix)
> > > +{
> > > +	struct device_node *np = card->dev->of_node;
> > > +	char prop[128];
> > > +	int ret = 0;
> > > +
> > > +	snprintf(prop, sizeof(prop), "%swidgets", prefix);
> > > +
> > > +	if (of_property_read_bool(np, prop))
> > > +		ret = snd_soc_of_parse_audio_simple_widgets(card, prop);
> > > +
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_widgets);
> > 
> > This seems like an extremely thin wrapper around existing core
> > functionality, shouldn't we just be adding the property check into the
> > core?
> 
> OK, will do in v2

This, and asoc_simple_card_parse_card_route() (= _route) had same concept.
(_widgets user is only simple-card...)
Many drivers are using _route function, and almost all drivers are expecting
that it will be error if DT doesn't have its property.
But, above helper is tring to parse it, and it is not error if DT doesn't have it.
I will put these 2 helper in soc-core.c, as _try_ function in v2.
diff mbox

Patch

diff --git a/include/sound/simple_card_core.h b/include/sound/simple_card_core.h
index d66b536..41a66e8 100644
--- a/include/sound/simple_card_core.h
+++ b/include/sound/simple_card_core.h
@@ -39,5 +39,7 @@  int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card,
 				       char *prefix);
 int asoc_simple_card_parse_card_route(struct snd_soc_card *card,
 				      char *prefix);
+int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card,
+					char *prefix);
 
 #endif /* __SIMPLE_CARD_CORE_H */
diff --git a/sound/soc/generic/simple-card-core.c b/sound/soc/generic/simple-card-core.c
index bfe3bf4..baabb50 100644
--- a/sound/soc/generic/simple-card-core.c
+++ b/sound/soc/generic/simple-card-core.c
@@ -158,3 +158,19 @@  int asoc_simple_card_parse_card_route(struct snd_soc_card *card,
 	return ret;
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_route);
+
+int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card,
+					char *prefix)
+{
+	struct device_node *np = card->dev->of_node;
+	char prop[128];
+	int ret = 0;
+
+	snprintf(prop, sizeof(prop), "%swidgets", prefix);
+
+	if (of_property_read_bool(np, prop))
+		ret = snd_soc_of_parse_audio_simple_widgets(card, prop);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_widgets);