aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-core.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 935721062c21..d7595465cfbc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3231,7 +3231,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3231 const char *propname) 3231 const char *propname)
3232{ 3232{
3233 struct device_node *np = card->dev->of_node; 3233 struct device_node *np = card->dev->of_node;
3234 int num_routes, old_routes; 3234 int num_routes;
3235 struct snd_soc_dapm_route *routes; 3235 struct snd_soc_dapm_route *routes;
3236 int i, ret; 3236 int i, ret;
3237 3237
@@ -3249,9 +3249,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3249 return -EINVAL; 3249 return -EINVAL;
3250 } 3250 }
3251 3251
3252 old_routes = card->num_dapm_routes; 3252 routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
3253 routes = devm_kzalloc(card->dev,
3254 (old_routes + num_routes) * sizeof(*routes),
3255 GFP_KERNEL); 3253 GFP_KERNEL);
3256 if (!routes) { 3254 if (!routes) {
3257 dev_err(card->dev, 3255 dev_err(card->dev,
@@ -3259,11 +3257,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3259 return -EINVAL; 3257 return -EINVAL;
3260 } 3258 }
3261 3259
3262 memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
3263
3264 for (i = 0; i < num_routes; i++) { 3260 for (i = 0; i < num_routes; i++) {
3265 ret = of_property_read_string_index(np, propname, 3261 ret = of_property_read_string_index(np, propname,
3266 2 * i, &routes[old_routes + i].sink); 3262 2 * i, &routes[i].sink);
3267 if (ret) { 3263 if (ret) {
3268 dev_err(card->dev, 3264 dev_err(card->dev,
3269 "ASoC: Property '%s' index %d could not be read: %d\n", 3265 "ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3271,7 +3267,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3271 return -EINVAL; 3267 return -EINVAL;
3272 } 3268 }
3273 ret = of_property_read_string_index(np, propname, 3269 ret = of_property_read_string_index(np, propname,
3274 (2 * i) + 1, &routes[old_routes + i].source); 3270 (2 * i) + 1, &routes[i].source);
3275 if (ret) { 3271 if (ret) {
3276 dev_err(card->dev, 3272 dev_err(card->dev,
3277 "ASoC: Property '%s' index %d could not be read: %d\n", 3273 "ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3280,7 +3276,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3280 } 3276 }
3281 } 3277 }
3282 3278
3283 card->num_dapm_routes += num_routes; 3279 card->num_dapm_routes = num_routes;
3284 card->dapm_routes = routes; 3280 card->dapm_routes = routes;
3285 3281
3286 return 0; 3282 return 0;