Skip to content

Commit

Permalink
Merge remote-tracking branch 'asoc/fix/dapm' into asoc-linus
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Dec 24, 2014
2 parents 97bf6af + e3b1e6a commit c533b8e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3230,7 +3230,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname)
{
struct device_node *np = card->dev->of_node;
int num_routes, old_routes;
int num_routes;
struct snd_soc_dapm_route *routes;
int i, ret;

Expand All @@ -3248,29 +3248,25 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
return -EINVAL;
}

old_routes = card->num_dapm_routes;
routes = devm_kzalloc(card->dev,
(old_routes + num_routes) * sizeof(*routes),
routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
GFP_KERNEL);
if (!routes) {
dev_err(card->dev,
"ASoC: Could not allocate DAPM route table\n");
return -EINVAL;
}

memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));

for (i = 0; i < num_routes; i++) {
ret = of_property_read_string_index(np, propname,
2 * i, &routes[old_routes + i].sink);
2 * i, &routes[i].sink);
if (ret) {
dev_err(card->dev,
"ASoC: Property '%s' index %d could not be read: %d\n",
propname, 2 * i, ret);
return -EINVAL;
}
ret = of_property_read_string_index(np, propname,
(2 * i) + 1, &routes[old_routes + i].source);
(2 * i) + 1, &routes[i].source);
if (ret) {
dev_err(card->dev,
"ASoC: Property '%s' index %d could not be read: %d\n",
Expand All @@ -3279,7 +3275,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
}
}

card->num_dapm_routes += num_routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = routes;

return 0;
Expand Down

0 comments on commit c533b8e

Please sign in to comment.