diff options
author | Mark Brown <broonie@kernel.org> | 2014-12-18 06:46:38 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-12-19 06:19:40 -0500 |
commit | e3b1e6a19e09877b91517dfe304a2b3f6b2138fc (patch) | |
tree | 97ddcc5907612a8c28aac14cb79f7d5aab8fcc48 /sound/soc/soc-core.c | |
parent | 1810afd3e1ded09c53d4e966dddce3c7d484521f (diff) |
ASoC: dapm: Remove snd_soc_of_parse_audio_routing() due to deferred probe
This reverts commit f8781db8aeb18d (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: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 14 |
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; |