Commit 46172b6c authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: dapm: Fix build warning

commit c6615082 ("ASoC: dapm: add code to configure dai link
parameters") introduced the following build warning:

sound/soc/soc-dapm.c: In function 'snd_soc_dapm_new_pcm':
sound/soc/soc-dapm.c:3389:4: warning: passing argument 1 of 'snprintf'
discards 'const' qualifier from pointer target type
snprintf(w_param_text[count], len,

This patch fixes this by switching to using devm_kasprintf. This also
saves a couple of lines of code.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent c6615082
...@@ -3356,7 +3356,6 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card, ...@@ -3356,7 +3356,6 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
{ {
struct snd_soc_dapm_widget template; struct snd_soc_dapm_widget template;
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
size_t len;
char *link_name; char *link_name;
int ret, count; int ret, count;
unsigned long private_value; unsigned long private_value;
...@@ -3376,28 +3375,26 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card, ...@@ -3376,28 +3375,26 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
if (!w_param_text) if (!w_param_text)
return -ENOMEM; return -ENOMEM;
len = strlen(source->name) + strlen(sink->name) + 2; link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s",
link_name = devm_kzalloc(card->dev, len, GFP_KERNEL); source->name, sink->name);
if (!link_name) { if (!link_name) {
ret = -ENOMEM; ret = -ENOMEM;
goto outfree_w_param; goto outfree_w_param;
} }
snprintf(link_name, len, "%s-%s", source->name, sink->name);
for (count = 0 ; count < num_params; count++) { for (count = 0 ; count < num_params; count++) {
if (!config->stream_name) { if (!config->stream_name) {
dev_warn(card->dapm.dev, dev_warn(card->dapm.dev,
"ASoC: anonymous config %d for dai link %s\n", "ASoC: anonymous config %d for dai link %s\n",
count, link_name); count, link_name);
len = strlen("Anonymous Configuration ") + 3;
w_param_text[count] = w_param_text[count] =
devm_kzalloc(card->dev, len, GFP_KERNEL); devm_kasprintf(card->dev, GFP_KERNEL,
"Anonymous Configuration %d",
count);
if (!w_param_text[count]) { if (!w_param_text[count]) {
ret = -ENOMEM; ret = -ENOMEM;
goto outfree_link_name; goto outfree_link_name;
} }
snprintf(w_param_text[count], len,
"Anonymous Configuration %d", count);
} else { } else {
w_param_text[count] = devm_kmemdup(card->dev, w_param_text[count] = devm_kmemdup(card->dev,
config->stream_name, config->stream_name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment