diff options
-rw-r--r-- | sound/soc/soc-core.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 443be0061129..b6e0e3134861 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -4585,7 +4585,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
4585 | const char *propname) | 4585 | const char *propname) |
4586 | { | 4586 | { |
4587 | struct device_node *np = card->dev->of_node; | 4587 | struct device_node *np = card->dev->of_node; |
4588 | int num_routes; | 4588 | int num_routes, old_routes; |
4589 | struct snd_soc_dapm_route *routes; | 4589 | struct snd_soc_dapm_route *routes; |
4590 | int i, ret; | 4590 | int i, ret; |
4591 | 4591 | ||
@@ -4603,7 +4603,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
4603 | return -EINVAL; | 4603 | return -EINVAL; |
4604 | } | 4604 | } |
4605 | 4605 | ||
4606 | routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes), | 4606 | old_routes = card->num_dapm_routes; |
4607 | routes = devm_kzalloc(card->dev, | ||
4608 | (old_routes + num_routes) * sizeof(*routes), | ||
4607 | GFP_KERNEL); | 4609 | GFP_KERNEL); |
4608 | if (!routes) { | 4610 | if (!routes) { |
4609 | dev_err(card->dev, | 4611 | dev_err(card->dev, |
@@ -4611,9 +4613,11 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
4611 | return -EINVAL; | 4613 | return -EINVAL; |
4612 | } | 4614 | } |
4613 | 4615 | ||
4616 | memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes)); | ||
4617 | |||
4614 | for (i = 0; i < num_routes; i++) { | 4618 | for (i = 0; i < num_routes; i++) { |
4615 | ret = of_property_read_string_index(np, propname, | 4619 | ret = of_property_read_string_index(np, propname, |
4616 | 2 * i, &routes[i].sink); | 4620 | 2 * i, &routes[old_routes + i].sink); |
4617 | if (ret) { | 4621 | if (ret) { |
4618 | dev_err(card->dev, | 4622 | dev_err(card->dev, |
4619 | "ASoC: Property '%s' index %d could not be read: %d\n", | 4623 | "ASoC: Property '%s' index %d could not be read: %d\n", |
@@ -4621,7 +4625,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
4621 | return -EINVAL; | 4625 | return -EINVAL; |
4622 | } | 4626 | } |
4623 | ret = of_property_read_string_index(np, propname, | 4627 | ret = of_property_read_string_index(np, propname, |
4624 | (2 * i) + 1, &routes[i].source); | 4628 | (2 * i) + 1, &routes[old_routes + i].source); |
4625 | if (ret) { | 4629 | if (ret) { |
4626 | dev_err(card->dev, | 4630 | dev_err(card->dev, |
4627 | "ASoC: Property '%s' index %d could not be read: %d\n", | 4631 | "ASoC: Property '%s' index %d could not be read: %d\n", |
@@ -4630,7 +4634,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
4630 | } | 4634 | } |
4631 | } | 4635 | } |
4632 | 4636 | ||
4633 | card->num_dapm_routes = num_routes; | 4637 | card->num_dapm_routes += num_routes; |
4634 | card->dapm_routes = routes; | 4638 | card->dapm_routes = routes; |
4635 | 4639 | ||
4636 | return 0; | 4640 | return 0; |