Message ID | 8760u9rrtl.wl%kuninori.morimoto.gx@renesas.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Geert Uytterhoeven |
Headers | show |
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?
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
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 --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);