aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-core.c1
-rw-r--r--sound/soc/soc-dapm.c35
2 files changed, 19 insertions, 17 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3a4a5c0e3f97..0e1e69c7abd5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1716,6 +1716,7 @@ card_probe_error:
1716 if (card->remove) 1716 if (card->remove)
1717 card->remove(card); 1717 card->remove(card);
1718 1718
1719 snd_soc_dapm_free(&card->dapm);
1719 soc_cleanup_card_debugfs(card); 1720 soc_cleanup_card_debugfs(card);
1720 snd_card_free(card->snd_card); 1721 snd_card_free(card->snd_card);
1721 1722
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index aa327c92480c..e0de8072c514 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -358,9 +358,10 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
358 data->widget = 358 data->widget =
359 snd_soc_dapm_new_control_unlocked(widget->dapm, 359 snd_soc_dapm_new_control_unlocked(widget->dapm,
360 &template); 360 &template);
361 kfree(name);
361 if (!data->widget) { 362 if (!data->widget) {
362 ret = -ENOMEM; 363 ret = -ENOMEM;
363 goto err_name; 364 goto err_data;
364 } 365 }
365 } 366 }
366 break; 367 break;
@@ -389,11 +390,12 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
389 390
390 data->value = template.on_val; 391 data->value = template.on_val;
391 392
392 data->widget = snd_soc_dapm_new_control(widget->dapm, 393 data->widget = snd_soc_dapm_new_control_unlocked(
393 &template); 394 widget->dapm, &template);
395 kfree(name);
394 if (!data->widget) { 396 if (!data->widget) {
395 ret = -ENOMEM; 397 ret = -ENOMEM;
396 goto err_name; 398 goto err_data;
397 } 399 }
398 400
399 snd_soc_dapm_add_path(widget->dapm, data->widget, 401 snd_soc_dapm_add_path(widget->dapm, data->widget,
@@ -408,8 +410,6 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
408 410
409 return 0; 411 return 0;
410 412
411err_name:
412 kfree(name);
413err_data: 413err_data:
414 kfree(data); 414 kfree(data);
415 return ret; 415 return ret;
@@ -418,8 +418,6 @@ err_data:
418static void dapm_kcontrol_free(struct snd_kcontrol *kctl) 418static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
419{ 419{
420 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl); 420 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
421 if (data->widget)
422 kfree(data->widget->name);
423 kfree(data->wlist); 421 kfree(data->wlist);
424 kfree(data); 422 kfree(data);
425} 423}
@@ -1952,6 +1950,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
1952 size_t count, loff_t *ppos) 1950 size_t count, loff_t *ppos)
1953{ 1951{
1954 struct snd_soc_dapm_widget *w = file->private_data; 1952 struct snd_soc_dapm_widget *w = file->private_data;
1953 struct snd_soc_card *card = w->dapm->card;
1955 char *buf; 1954 char *buf;
1956 int in, out; 1955 int in, out;
1957 ssize_t ret; 1956 ssize_t ret;
@@ -1961,6 +1960,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
1961 if (!buf) 1960 if (!buf)
1962 return -ENOMEM; 1961 return -ENOMEM;
1963 1962
1963 mutex_lock(&card->dapm_mutex);
1964
1964 /* Supply widgets are not handled by is_connected_{input,output}_ep() */ 1965 /* Supply widgets are not handled by is_connected_{input,output}_ep() */
1965 if (w->is_supply) { 1966 if (w->is_supply) {
1966 in = 0; 1967 in = 0;
@@ -2007,6 +2008,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
2007 p->sink->name); 2008 p->sink->name);
2008 } 2009 }
2009 2010
2011 mutex_unlock(&card->dapm_mutex);
2012
2010 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 2013 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
2011 2014
2012 kfree(buf); 2015 kfree(buf);
@@ -2281,11 +2284,15 @@ static ssize_t dapm_widget_show(struct device *dev,
2281 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); 2284 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
2282 int i, count = 0; 2285 int i, count = 0;
2283 2286
2287 mutex_lock(&rtd->card->dapm_mutex);
2288
2284 for (i = 0; i < rtd->num_codecs; i++) { 2289 for (i = 0; i < rtd->num_codecs; i++) {
2285 struct snd_soc_codec *codec = rtd->codec_dais[i]->codec; 2290 struct snd_soc_codec *codec = rtd->codec_dais[i]->codec;
2286 count += dapm_widget_show_codec(codec, buf + count); 2291 count += dapm_widget_show_codec(codec, buf + count);
2287 } 2292 }
2288 2293
2294 mutex_unlock(&rtd->card->dapm_mutex);
2295
2289 return count; 2296 return count;
2290} 2297}
2291 2298
@@ -3334,16 +3341,10 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
3334 } 3341 }
3335 3342
3336 prefix = soc_dapm_prefix(dapm); 3343 prefix = soc_dapm_prefix(dapm);
3337 if (prefix) { 3344 if (prefix)
3338 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name); 3345 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
3339 if (widget->sname) 3346 else
3340 w->sname = kasprintf(GFP_KERNEL, "%s %s", prefix,
3341 widget->sname);
3342 } else {
3343 w->name = kasprintf(GFP_KERNEL, "%s", widget->name); 3347 w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
3344 if (widget->sname)
3345 w->sname = kasprintf(GFP_KERNEL, "%s", widget->sname);
3346 }
3347 if (w->name == NULL) { 3348 if (w->name == NULL) {
3348 kfree(w); 3349 kfree(w);
3349 return NULL; 3350 return NULL;
@@ -3792,7 +3793,7 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
3792 break; 3793 break;
3793 } 3794 }
3794 3795
3795 if (!w->sname || !strstr(w->sname, dai_w->name)) 3796 if (!w->sname || !strstr(w->sname, dai_w->sname))
3796 continue; 3797 continue;
3797 3798
3798 if (dai_w->id == snd_soc_dapm_dai_in) { 3799 if (dai_w->id == snd_soc_dapm_dai_in) {