diff options
| -rw-r--r-- | include/sound/soc-dapm.h | 1 | ||||
| -rw-r--r-- | sound/soc/soc-dapm.c | 38 | ||||
| -rw-r--r-- | sound/soc/soc-topology.c | 25 |
3 files changed, 24 insertions, 40 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 37d95a898275..cadc7fc5d727 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
| @@ -397,6 +397,7 @@ int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, | |||
| 397 | const struct snd_soc_dapm_route *route, int num); | 397 | const struct snd_soc_dapm_route *route, int num); |
| 398 | int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, | 398 | int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, |
| 399 | const struct snd_soc_dapm_route *route, int num); | 399 | const struct snd_soc_dapm_route *route, int num); |
| 400 | void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w); | ||
| 400 | 401 | ||
| 401 | /* dapm events */ | 402 | /* dapm events */ |
| 402 | void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, | 403 | void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e0de8072c514..24ea692bd49e 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -2312,30 +2312,36 @@ static void dapm_free_path(struct snd_soc_dapm_path *path) | |||
| 2312 | kfree(path); | 2312 | kfree(path); |
| 2313 | } | 2313 | } |
| 2314 | 2314 | ||
| 2315 | void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) | ||
| 2316 | { | ||
| 2317 | struct snd_soc_dapm_path *p, *next_p; | ||
| 2318 | |||
| 2319 | list_del(&w->list); | ||
| 2320 | /* | ||
| 2321 | * remove source and sink paths associated to this widget. | ||
| 2322 | * While removing the path, remove reference to it from both | ||
| 2323 | * source and sink widgets so that path is removed only once. | ||
| 2324 | */ | ||
| 2325 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) | ||
| 2326 | dapm_free_path(p); | ||
| 2327 | |||
| 2328 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) | ||
| 2329 | dapm_free_path(p); | ||
| 2330 | |||
| 2331 | kfree(w->kcontrols); | ||
| 2332 | kfree(w->name); | ||
| 2333 | kfree(w); | ||
| 2334 | } | ||
| 2335 | |||
| 2315 | /* free all dapm widgets and resources */ | 2336 | /* free all dapm widgets and resources */ |
| 2316 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) | 2337 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) |
| 2317 | { | 2338 | { |
| 2318 | struct snd_soc_dapm_widget *w, *next_w; | 2339 | struct snd_soc_dapm_widget *w, *next_w; |
| 2319 | struct snd_soc_dapm_path *p, *next_p; | ||
| 2320 | 2340 | ||
| 2321 | list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { | 2341 | list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { |
| 2322 | if (w->dapm != dapm) | 2342 | if (w->dapm != dapm) |
| 2323 | continue; | 2343 | continue; |
| 2324 | list_del(&w->list); | 2344 | snd_soc_dapm_free_widget(w); |
| 2325 | /* | ||
| 2326 | * remove source and sink paths associated to this widget. | ||
| 2327 | * While removing the path, remove reference to it from both | ||
| 2328 | * source and sink widgets so that path is removed only once. | ||
| 2329 | */ | ||
| 2330 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) | ||
| 2331 | dapm_free_path(p); | ||
| 2332 | |||
| 2333 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) | ||
| 2334 | dapm_free_path(p); | ||
| 2335 | |||
| 2336 | kfree(w->kcontrols); | ||
| 2337 | kfree(w->name); | ||
| 2338 | kfree(w); | ||
| 2339 | } | 2345 | } |
| 2340 | } | 2346 | } |
| 2341 | 2347 | ||
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index d0960683c409..56dd108d6f5f 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c | |||
| @@ -1734,7 +1734,6 @@ void snd_soc_tplg_widget_remove_all(struct snd_soc_dapm_context *dapm, | |||
| 1734 | u32 index) | 1734 | u32 index) |
| 1735 | { | 1735 | { |
| 1736 | struct snd_soc_dapm_widget *w, *next_w; | 1736 | struct snd_soc_dapm_widget *w, *next_w; |
| 1737 | struct snd_soc_dapm_path *p, *next_p; | ||
| 1738 | 1737 | ||
| 1739 | list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { | 1738 | list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { |
| 1740 | 1739 | ||
| @@ -1746,31 +1745,9 @@ void snd_soc_tplg_widget_remove_all(struct snd_soc_dapm_context *dapm, | |||
| 1746 | if (w->dobj.index != index && | 1745 | if (w->dobj.index != index && |
| 1747 | w->dobj.index != SND_SOC_TPLG_INDEX_ALL) | 1746 | w->dobj.index != SND_SOC_TPLG_INDEX_ALL) |
| 1748 | continue; | 1747 | continue; |
| 1749 | |||
| 1750 | list_del(&w->list); | ||
| 1751 | |||
| 1752 | /* | ||
| 1753 | * remove source and sink paths associated to this widget. | ||
| 1754 | * While removing the path, remove reference to it from both | ||
| 1755 | * source and sink widgets so that path is removed only once. | ||
| 1756 | */ | ||
| 1757 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) { | ||
| 1758 | list_del(&p->list_sink); | ||
| 1759 | list_del(&p->list_source); | ||
| 1760 | list_del(&p->list); | ||
| 1761 | kfree(p); | ||
| 1762 | } | ||
| 1763 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) { | ||
| 1764 | list_del(&p->list_sink); | ||
| 1765 | list_del(&p->list_source); | ||
| 1766 | list_del(&p->list); | ||
| 1767 | kfree(p); | ||
| 1768 | } | ||
| 1769 | /* check and free and dynamic widget kcontrols */ | 1748 | /* check and free and dynamic widget kcontrols */ |
| 1770 | snd_soc_tplg_widget_remove(w); | 1749 | snd_soc_tplg_widget_remove(w); |
| 1771 | kfree(w->kcontrols); | 1750 | snd_soc_dapm_free_widget(w); |
| 1772 | kfree(w->name); | ||
| 1773 | kfree(w); | ||
| 1774 | } | 1751 | } |
| 1775 | } | 1752 | } |
| 1776 | EXPORT_SYMBOL_GPL(snd_soc_tplg_widget_remove_all); | 1753 | EXPORT_SYMBOL_GPL(snd_soc_tplg_widget_remove_all); |
