diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-06-14 07:16:53 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-06-14 07:34:11 -0400 |
commit | 8872293fc38c4906c86e7d335b8f936abf9e4531 (patch) | |
tree | 2981a659bcaf70c051cd18a4fc661db35b3dbb43 /sound | |
parent | 58fee775b7a18a0174931af6174536560785d500 (diff) |
ASoC: dapm: Add a helper function to free a DAPM path
We have the same code for freeing a DAPM path in three different locations.
Introduce a new helper function to take care of this.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-dapm.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 8d8a8dc6857e..784534dcc82d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -2105,6 +2105,15 @@ static void snd_soc_dapm_sys_remove(struct device *dev) | |||
2105 | device_remove_file(dev, &dev_attr_dapm_widget); | 2105 | device_remove_file(dev, &dev_attr_dapm_widget); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | static void dapm_free_path(struct snd_soc_dapm_path *path) | ||
2109 | { | ||
2110 | list_del(&path->list_sink); | ||
2111 | list_del(&path->list_source); | ||
2112 | list_del(&path->list); | ||
2113 | kfree(path->long_name); | ||
2114 | kfree(path); | ||
2115 | } | ||
2116 | |||
2108 | /* free all dapm widgets and resources */ | 2117 | /* free all dapm widgets and resources */ |
2109 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) | 2118 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) |
2110 | { | 2119 | { |
@@ -2120,20 +2129,12 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) | |||
2120 | * While removing the path, remove reference to it from both | 2129 | * While removing the path, remove reference to it from both |
2121 | * source and sink widgets so that path is removed only once. | 2130 | * source and sink widgets so that path is removed only once. |
2122 | */ | 2131 | */ |
2123 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) { | 2132 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) |
2124 | list_del(&p->list_sink); | 2133 | dapm_free_path(p); |
2125 | list_del(&p->list_source); | 2134 | |
2126 | list_del(&p->list); | 2135 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) |
2127 | kfree(p->long_name); | 2136 | dapm_free_path(p); |
2128 | kfree(p); | 2137 | |
2129 | } | ||
2130 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) { | ||
2131 | list_del(&p->list_sink); | ||
2132 | list_del(&p->list_source); | ||
2133 | list_del(&p->list); | ||
2134 | kfree(p->long_name); | ||
2135 | kfree(p); | ||
2136 | } | ||
2137 | kfree(w->kcontrols); | 2138 | kfree(w->kcontrols); |
2138 | kfree(w->name); | 2139 | kfree(w->name); |
2139 | kfree(w); | 2140 | kfree(w); |
@@ -2408,10 +2409,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, | |||
2408 | dapm_mark_dirty(path->source, "Route removed"); | 2409 | dapm_mark_dirty(path->source, "Route removed"); |
2409 | dapm_mark_dirty(path->sink, "Route removed"); | 2410 | dapm_mark_dirty(path->sink, "Route removed"); |
2410 | 2411 | ||
2411 | list_del(&path->list); | 2412 | dapm_free_path(path); |
2412 | list_del(&path->list_sink); | ||
2413 | list_del(&path->list_source); | ||
2414 | kfree(path); | ||
2415 | } else { | 2413 | } else { |
2416 | dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", | 2414 | dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", |
2417 | source, sink); | 2415 | source, sink); |