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 397d00aee43f..d8d5449cc48e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -3536,7 +3536,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
3536 | const char *propname) | 3536 | const char *propname) |
3537 | { | 3537 | { |
3538 | struct device_node *np = card->dev->of_node; | 3538 | struct device_node *np = card->dev->of_node; |
3539 | int num_routes; | 3539 | int num_routes, old_routes; |
3540 | struct snd_soc_dapm_route *routes; | 3540 | struct snd_soc_dapm_route *routes; |
3541 | int i, ret; | 3541 | int i, ret; |
3542 | 3542 | ||
@@ -3554,7 +3554,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
3554 | return -EINVAL; | 3554 | return -EINVAL; |
3555 | } | 3555 | } |
3556 | 3556 | ||
3557 | routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes), | 3557 | old_routes = card->num_dapm_routes; |
3558 | routes = devm_kzalloc(card->dev, | ||
3559 | (old_routes + num_routes) * sizeof(*routes), | ||
3558 | GFP_KERNEL); | 3560 | GFP_KERNEL); |
3559 | if (!routes) { | 3561 | if (!routes) { |
3560 | dev_err(card->dev, | 3562 | dev_err(card->dev, |
@@ -3562,9 +3564,11 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
3562 | return -EINVAL; | 3564 | return -EINVAL; |
3563 | } | 3565 | } |
3564 | 3566 | ||
3567 | memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes)); | ||
3568 | |||
3565 | for (i = 0; i < num_routes; i++) { | 3569 | for (i = 0; i < num_routes; i++) { |
3566 | ret = of_property_read_string_index(np, propname, | 3570 | ret = of_property_read_string_index(np, propname, |
3567 | 2 * i, &routes[i].sink); | 3571 | 2 * i, &routes[old_routes + i].sink); |
3568 | if (ret) { | 3572 | if (ret) { |
3569 | dev_err(card->dev, | 3573 | dev_err(card->dev, |
3570 | "ASoC: Property '%s' index %d could not be read: %d\n", | 3574 | "ASoC: Property '%s' index %d could not be read: %d\n", |
@@ -3572,7 +3576,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
3572 | return -EINVAL; | 3576 | return -EINVAL; |
3573 | } | 3577 | } |
3574 | ret = of_property_read_string_index(np, propname, | 3578 | ret = of_property_read_string_index(np, propname, |
3575 | (2 * i) + 1, &routes[i].source); | 3579 | (2 * i) + 1, &routes[old_routes + i].source); |
3576 | if (ret) { | 3580 | if (ret) { |
3577 | dev_err(card->dev, | 3581 | dev_err(card->dev, |
3578 | "ASoC: Property '%s' index %d could not be read: %d\n", | 3582 | "ASoC: Property '%s' index %d could not be read: %d\n", |
@@ -3581,7 +3585,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
3581 | } | 3585 | } |
3582 | } | 3586 | } |
3583 | 3587 | ||
3584 | card->num_dapm_routes = num_routes; | 3588 | card->num_dapm_routes += num_routes; |
3585 | card->dapm_routes = routes; | 3589 | card->dapm_routes = routes; |
3586 | 3590 | ||
3587 | return 0; | 3591 | return 0; |