Skip to content

Commit

Permalink
Merge remote-tracking branch 'asoc/fix/dapm' into asoc-linus
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Jul 24, 2015
2 parents 52721d9 + a798c24 commit 61710a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
if (card->remove)
card->remove(card);

snd_soc_dapm_free(&card->dapm);
soc_cleanup_card_debugfs(card);
snd_card_free(card->snd_card);

Expand Down
35 changes: 18 additions & 17 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,10 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
data->widget =
snd_soc_dapm_new_control_unlocked(widget->dapm,
&template);
kfree(name);
if (!data->widget) {
ret = -ENOMEM;
goto err_name;
goto err_data;
}
}
break;
Expand Down Expand Up @@ -389,11 +390,12 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,

data->value = template.on_val;

data->widget = snd_soc_dapm_new_control(widget->dapm,
&template);
data->widget = snd_soc_dapm_new_control_unlocked(
widget->dapm, &template);
kfree(name);
if (!data->widget) {
ret = -ENOMEM;
goto err_name;
goto err_data;
}

snd_soc_dapm_add_path(widget->dapm, data->widget,
Expand All @@ -408,8 +410,6 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,

return 0;

err_name:
kfree(name);
err_data:
kfree(data);
return ret;
Expand All @@ -418,8 +418,6 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
{
struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
if (data->widget)
kfree(data->widget->name);
kfree(data->wlist);
kfree(data);
}
Expand Down Expand Up @@ -1952,6 +1950,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
size_t count, loff_t *ppos)
{
struct snd_soc_dapm_widget *w = file->private_data;
struct snd_soc_card *card = w->dapm->card;
char *buf;
int in, out;
ssize_t ret;
Expand All @@ -1961,6 +1960,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
if (!buf)
return -ENOMEM;

mutex_lock(&card->dapm_mutex);

/* Supply widgets are not handled by is_connected_{input,output}_ep() */
if (w->is_supply) {
in = 0;
Expand Down Expand Up @@ -2007,6 +2008,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
p->sink->name);
}

mutex_unlock(&card->dapm_mutex);

ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);

kfree(buf);
Expand Down Expand Up @@ -2281,11 +2284,15 @@ static ssize_t dapm_widget_show(struct device *dev,
struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
int i, count = 0;

mutex_lock(&rtd->card->dapm_mutex);

for (i = 0; i < rtd->num_codecs; i++) {
struct snd_soc_codec *codec = rtd->codec_dais[i]->codec;
count += dapm_widget_show_codec(codec, buf + count);
}

mutex_unlock(&rtd->card->dapm_mutex);

return count;
}

Expand Down Expand Up @@ -3334,16 +3341,10 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
}

prefix = soc_dapm_prefix(dapm);
if (prefix) {
if (prefix)
w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
if (widget->sname)
w->sname = kasprintf(GFP_KERNEL, "%s %s", prefix,
widget->sname);
} else {
else
w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
if (widget->sname)
w->sname = kasprintf(GFP_KERNEL, "%s", widget->sname);
}
if (w->name == NULL) {
kfree(w);
return NULL;
Expand Down Expand Up @@ -3792,7 +3793,7 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
break;
}

if (!w->sname || !strstr(w->sname, dai_w->name))
if (!w->sname || !strstr(w->sname, dai_w->sname))
continue;

if (dai_w->id == snd_soc_dapm_dai_in) {
Expand Down

0 comments on commit 61710a6

Please sign in to comment.