diff options
author | Mark Brown <broonie@linaro.org> | 2013-06-17 12:20:17 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-06-17 12:20:17 -0400 |
commit | 9805fe391d918d5127530ca7741904407d28f428 (patch) | |
tree | 3f744f9fc4a7fea5e5ca8e2e0558723828e3b1d3 | |
parent | 70fe99d8dbbcff8b61b613e738e9d133ed2d2b15 (diff) | |
parent | 656ca9d327a3dbac6db28c5bf80f5bc86f7f8548 (diff) |
Merge remote-tracking branch 'asoc/topic/dapm' into asoc-next
-rw-r--r-- | include/sound/soc-dapm.h | 1 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 61 |
2 files changed, 30 insertions, 32 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 69e8e0799d4d..3e479f4e15f5 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
@@ -481,7 +481,6 @@ struct snd_soc_dapm_route { | |||
481 | /* dapm audio path between two widgets */ | 481 | /* dapm audio path between two widgets */ |
482 | struct snd_soc_dapm_path { | 482 | struct snd_soc_dapm_path { |
483 | const char *name; | 483 | const char *name; |
484 | const char *long_name; | ||
485 | 484 | ||
486 | /* source (input) and sink (output) widgets */ | 485 | /* source (input) and sink (output) widgets */ |
487 | struct snd_soc_dapm_widget *source; | 486 | struct snd_soc_dapm_widget *source; |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 10290c71f5b6..b94190820e8c 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -367,11 +367,10 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
367 | val = soc_widget_read(w, e->reg); | 367 | val = soc_widget_read(w, e->reg); |
368 | item = (val >> e->shift_l) & e->mask; | 368 | item = (val >> e->shift_l) & e->mask; |
369 | 369 | ||
370 | p->connect = 0; | 370 | if (item < e->max && !strcmp(p->name, e->texts[item])) |
371 | for (i = 0; i < e->max; i++) { | 371 | p->connect = 1; |
372 | if (!(strcmp(p->name, e->texts[i])) && item == i) | 372 | else |
373 | p->connect = 1; | 373 | p->connect = 0; |
374 | } | ||
375 | } | 374 | } |
376 | break; | 375 | break; |
377 | case snd_soc_dapm_virt_mux: { | 376 | case snd_soc_dapm_virt_mux: { |
@@ -401,11 +400,10 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
401 | break; | 400 | break; |
402 | } | 401 | } |
403 | 402 | ||
404 | p->connect = 0; | 403 | if (item < e->max && !strcmp(p->name, e->texts[item])) |
405 | for (i = 0; i < e->max; i++) { | 404 | p->connect = 1; |
406 | if (!(strcmp(p->name, e->texts[i])) && item == i) | 405 | else |
407 | p->connect = 1; | 406 | p->connect = 0; |
408 | } | ||
409 | } | 407 | } |
410 | break; | 408 | break; |
411 | /* does not affect routing - always connected */ | 409 | /* does not affect routing - always connected */ |
@@ -509,6 +507,11 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, | |||
509 | return 0; | 507 | return 0; |
510 | } | 508 | } |
511 | 509 | ||
510 | static void dapm_kcontrol_free(struct snd_kcontrol *kctl) | ||
511 | { | ||
512 | kfree(kctl->private_data); | ||
513 | } | ||
514 | |||
512 | /* | 515 | /* |
513 | * Determine if a kcontrol is shared. If it is, look it up. If it isn't, | 516 | * Determine if a kcontrol is shared. If it is, look it up. If it isn't, |
514 | * create it. Either way, add the widget into the control's widget list | 517 | * create it. Either way, add the widget into the control's widget list |
@@ -615,17 +618,16 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, | |||
615 | 618 | ||
616 | kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], wlist, name, | 619 | kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], wlist, name, |
617 | prefix); | 620 | prefix); |
621 | kcontrol->private_free = dapm_kcontrol_free; | ||
622 | kfree(long_name); | ||
618 | ret = snd_ctl_add(card, kcontrol); | 623 | ret = snd_ctl_add(card, kcontrol); |
619 | if (ret < 0) { | 624 | if (ret < 0) { |
620 | dev_err(dapm->dev, | 625 | dev_err(dapm->dev, |
621 | "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", | 626 | "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", |
622 | w->name, name, ret); | 627 | w->name, name, ret); |
623 | kfree(wlist); | 628 | kfree(wlist); |
624 | kfree(long_name); | ||
625 | return ret; | 629 | return ret; |
626 | } | 630 | } |
627 | |||
628 | path->long_name = long_name; | ||
629 | } | 631 | } |
630 | 632 | ||
631 | kcontrol->private_data = wlist; | 633 | kcontrol->private_data = wlist; |
@@ -2105,6 +2107,14 @@ static void snd_soc_dapm_sys_remove(struct device *dev) | |||
2105 | device_remove_file(dev, &dev_attr_dapm_widget); | 2107 | device_remove_file(dev, &dev_attr_dapm_widget); |
2106 | } | 2108 | } |
2107 | 2109 | ||
2110 | static void dapm_free_path(struct snd_soc_dapm_path *path) | ||
2111 | { | ||
2112 | list_del(&path->list_sink); | ||
2113 | list_del(&path->list_source); | ||
2114 | list_del(&path->list); | ||
2115 | kfree(path); | ||
2116 | } | ||
2117 | |||
2108 | /* free all dapm widgets and resources */ | 2118 | /* free all dapm widgets and resources */ |
2109 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) | 2119 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) |
2110 | { | 2120 | { |
@@ -2120,20 +2130,12 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) | |||
2120 | * While removing the path, remove reference to it from both | 2130 | * While removing the path, remove reference to it from both |
2121 | * source and sink widgets so that path is removed only once. | 2131 | * source and sink widgets so that path is removed only once. |
2122 | */ | 2132 | */ |
2123 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) { | 2133 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) |
2124 | list_del(&p->list_sink); | 2134 | dapm_free_path(p); |
2125 | list_del(&p->list_source); | 2135 | |
2126 | list_del(&p->list); | 2136 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) |
2127 | kfree(p->long_name); | 2137 | dapm_free_path(p); |
2128 | kfree(p); | 2138 | |
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); | 2139 | kfree(w->kcontrols); |
2138 | kfree(w->name); | 2140 | kfree(w->name); |
2139 | kfree(w); | 2141 | kfree(w); |
@@ -2409,10 +2411,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, | |||
2409 | dapm_mark_dirty(path->source, "Route removed"); | 2411 | dapm_mark_dirty(path->source, "Route removed"); |
2410 | dapm_mark_dirty(path->sink, "Route removed"); | 2412 | dapm_mark_dirty(path->sink, "Route removed"); |
2411 | 2413 | ||
2412 | list_del(&path->list); | 2414 | dapm_free_path(path); |
2413 | list_del(&path->list_sink); | ||
2414 | list_del(&path->list_source); | ||
2415 | kfree(path); | ||
2416 | } else { | 2415 | } else { |
2417 | dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", | 2416 | dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", |
2418 | source, sink); | 2417 | source, sink); |