Commit e3b1e6a1 authored by Mark Brown's avatar Mark Brown

ASoC: dapm: Remove snd_soc_of_parse_audio_routing() due to deferred probe

This reverts commit f8781db8 (ASoC: dapm: Augment existing card
DAPM routes in snd_soc_of_parse_audio_routing) since it is broken for
deferred probing as it ends up storing data allocated with devm_ over
multiple instantiations of the device.
Reported-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Tested-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1810afd3
......@@ -3231,7 +3231,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;
......@@ -3249,9 +3249,7 @@ 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,
......@@ -3259,11 +3257,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
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",
......@@ -3271,7 +3267,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
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",
......@@ -3280,7 +3276,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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment