提交 52008472 编写于 作者: J Jean-Francois Moine 提交者: Mark Brown

ASoC: simple-card: simplify code

The CPU and CODEC DAI names are still copied to the user info structure.
Put them directly in the DAI links.
Signed-off-by: NJean-Francois Moine <moinejf@free.fr>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 5ca8ba41
...@@ -60,7 +60,8 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) ...@@ -60,7 +60,8 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
static int static int
asoc_simple_card_sub_parse_of(struct device_node *np, asoc_simple_card_sub_parse_of(struct device_node *np,
struct asoc_simple_dai *dai, struct asoc_simple_dai *dai,
const struct device_node **p_node) const struct device_node **p_node,
const char **name)
{ {
struct device_node *node; struct device_node *node;
struct clk *clk; struct clk *clk;
...@@ -76,7 +77,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, ...@@ -76,7 +77,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
*p_node = node; *p_node = node;
/* get dai->name */ /* get dai->name */
ret = snd_soc_of_get_dai_name(np, &dai->name); ret = snd_soc_of_get_dai_name(np, name);
if (ret < 0) if (ret < 0)
goto parse_error; goto parse_error;
...@@ -146,7 +147,8 @@ static int asoc_simple_card_parse_of(struct device_node *node, ...@@ -146,7 +147,8 @@ static int asoc_simple_card_parse_of(struct device_node *node,
if (np) if (np)
ret = asoc_simple_card_sub_parse_of(np, ret = asoc_simple_card_sub_parse_of(np,
&info->cpu_dai, &info->cpu_dai,
&dai_link->cpu_of_node); &dai_link->cpu_of_node,
&dai_link->cpu_dai_name);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -156,19 +158,21 @@ static int asoc_simple_card_parse_of(struct device_node *node, ...@@ -156,19 +158,21 @@ static int asoc_simple_card_parse_of(struct device_node *node,
if (np) if (np)
ret = asoc_simple_card_sub_parse_of(np, ret = asoc_simple_card_sub_parse_of(np,
&info->codec_dai, &info->codec_dai,
&dai_link->codec_of_node); &dai_link->codec_of_node,
&dai_link->codec_dai_name);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (!info->cpu_dai.name || !info->codec_dai.name) if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name)
return -EINVAL; return -EINVAL;
/* card name is created from CPU/CODEC dai name */ /* card name is created from CPU/CODEC dai name */
name = devm_kzalloc(dev, name = devm_kzalloc(dev,
strlen(info->cpu_dai.name) + strlen(dai_link->cpu_dai_name) +
strlen(info->codec_dai.name) + 2, strlen(dai_link->codec_dai_name) + 2,
GFP_KERNEL); GFP_KERNEL);
sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name); sprintf(name, "%s-%s", dai_link->cpu_dai_name,
dai_link->codec_dai_name);
info->snd_card.name = name; info->snd_card.name = name;
dai_link->name = dai_link->stream_name = name; dai_link->name = dai_link->stream_name = name;
...@@ -178,11 +182,11 @@ static int asoc_simple_card_parse_of(struct device_node *node, ...@@ -178,11 +182,11 @@ static int asoc_simple_card_parse_of(struct device_node *node,
dev_dbg(dev, "card-name : %s\n", name); dev_dbg(dev, "card-name : %s\n", name);
dev_dbg(dev, "platform : %04x\n", info->daifmt); dev_dbg(dev, "platform : %04x\n", info->daifmt);
dev_dbg(dev, "cpu : %s / %04x / %d\n", dev_dbg(dev, "cpu : %s / %04x / %d\n",
info->cpu_dai.name, dai_link->cpu_dai_name,
info->cpu_dai.fmt, info->cpu_dai.fmt,
info->cpu_dai.sysclk); info->cpu_dai.sysclk);
dev_dbg(dev, "codec : %s / %04x / %d\n", dev_dbg(dev, "codec : %s / %04x / %d\n",
info->codec_dai.name, dai_link->codec_dai_name,
info->codec_dai.fmt, info->codec_dai.fmt,
info->codec_dai.sysclk); info->codec_dai.sysclk);
...@@ -240,13 +244,13 @@ static int asoc_simple_card_probe(struct platform_device *pdev) ...@@ -240,13 +244,13 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
dai_link->stream_name = cinfo->name; dai_link->stream_name = cinfo->name;
dai_link->platform_name = cinfo->platform; dai_link->platform_name = cinfo->platform;
dai_link->codec_name = cinfo->codec; dai_link->codec_name = cinfo->codec;
dai_link->cpu_dai_name = cinfo->cpu_dai.name;
dai_link->codec_dai_name = cinfo->codec_dai.name;
} }
/* /*
* init snd_soc_dai_link * init snd_soc_dai_link
*/ */
dai_link->cpu_dai_name = cinfo->cpu_dai.name;
dai_link->codec_dai_name = cinfo->codec_dai.name;
dai_link->init = asoc_simple_card_dai_init; dai_link->init = asoc_simple_card_dai_init;
snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo); snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册