aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 51eef9b7b53f..42ad2db8f082 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3342,6 +3342,63 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
3342} 3342}
3343EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name); 3343EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);
3344 3344
3345int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3346 const char *propname)
3347{
3348 struct device_node *np = card->dev->of_node;
3349 int num_routes;
3350 struct snd_soc_dapm_route *routes;
3351 int i, ret;
3352
3353 num_routes = of_property_count_strings(np, propname);
3354 if (num_routes & 1) {
3355 dev_err(card->dev,
3356 "Property '%s's length is not even\n",
3357 propname);
3358 return -EINVAL;
3359 }
3360 num_routes /= 2;
3361 if (!num_routes) {
3362 dev_err(card->dev,
3363 "Property '%s's length is zero\n",
3364 propname);
3365 return -EINVAL;
3366 }
3367
3368 routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
3369 GFP_KERNEL);
3370 if (!routes) {
3371 dev_err(card->dev,
3372 "Could not allocate DAPM route table\n");
3373 return -EINVAL;
3374 }
3375
3376 for (i = 0; i < num_routes; i++) {
3377 ret = of_property_read_string_index(np, propname,
3378 2 * i, &routes[i].sink);
3379 if (ret) {
3380 dev_err(card->dev,
3381 "Property '%s' index %d could not be read: %d\n",
3382 propname, 2 * i, ret);
3383 return -EINVAL;
3384 }
3385 ret = of_property_read_string_index(np, propname,
3386 (2 * i) + 1, &routes[i].source);
3387 if (ret) {
3388 dev_err(card->dev,
3389 "Property '%s' index %d could not be read: %d\n",
3390 propname, (2 * i) + 1, ret);
3391 return -EINVAL;
3392 }
3393 }
3394
3395 card->num_dapm_routes = num_routes;
3396 card->dapm_routes = routes;
3397
3398 return 0;
3399}
3400EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);
3401
3345static int __init snd_soc_init(void) 3402static int __init snd_soc_init(void)
3346{ 3403{
3347#ifdef CONFIG_DEBUG_FS 3404#ifdef CONFIG_DEBUG_FS