ASoC: simple-card-utils: add asoc_simple_card_of_parse_widgets()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 16 Jun 2017 01:38:50 +0000 (01:38 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 16 Jun 2017 16:58:39 +0000 (17:58 +0100)
Current simple card drivers are parsing widgets on each own driver
(only simple-card at this point, but will be supported on all drivers)
Encapsulation is one of simple card util's purpose.
Let's add asoc_simple_card_of_parse_widgets for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/simple_card_utils.h
sound/soc/generic/simple-card-utils.c

index 889c8ff863698843492751c11c049263a2f93066..42c6a6ac3ce60d6ab81fc4e726e6dfe0129804ff 100644 (file)
@@ -103,5 +103,7 @@ void asoc_simple_card_parse_convert(struct device *dev, char *prefix,
 int asoc_simple_card_of_parse_routing(struct snd_soc_card *card,
                                      char *prefix,
                                      int optional);
+int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
+                                     char *prefix);
 
 #endif /* __SIMPLE_CARD_UTILS_H */
index a2b6d95bc2f90bc6c769f041d7f0f4c1f3477f78..26d64fa40c9cf1438f43a08d8f45b15ac0184fa9 100644 (file)
@@ -397,6 +397,25 @@ int asoc_simple_card_of_parse_routing(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_routing);
 
+int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
+                                     char *prefix)
+{
+       struct device_node *node = card->dev->of_node;
+       char prop[128];
+
+       if (!prefix)
+               prefix = "";
+
+       snprintf(prop, sizeof(prop), "%s%s", prefix, "widgets");
+
+       if (of_property_read_bool(node, prop))
+               return snd_soc_of_parse_audio_simple_widgets(card, prop);
+
+       /* no widgets is not error */
+       return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_widgets);
+
 /* Module information */
 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
 MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");