diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2014-01-15 10:51:48 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-03 07:45:33 -0500 |
commit | 520084729267ac8df1651ad2f118a1d4a631a10a (patch) | |
tree | b74f1f98b0081c594347025737784c1d5ae1023b /sound/soc/generic | |
parent | 5ca8ba4180a6f629d51dba699b4a6428cc5eeba7 (diff) |
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: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r-- | sound/soc/generic/simple-card.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 797696fc6f12..9068ab474ab4 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -60,7 +60,8 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) | |||
60 | static int | 60 | static int |
61 | asoc_simple_card_sub_parse_of(struct device_node *np, | 61 | asoc_simple_card_sub_parse_of(struct device_node *np, |
62 | struct asoc_simple_dai *dai, | 62 | struct asoc_simple_dai *dai, |
63 | const struct device_node **p_node) | 63 | const struct device_node **p_node, |
64 | const char **name) | ||
64 | { | 65 | { |
65 | struct device_node *node; | 66 | struct device_node *node; |
66 | struct clk *clk; | 67 | struct clk *clk; |
@@ -76,7 +77,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, | |||
76 | *p_node = node; | 77 | *p_node = node; |
77 | 78 | ||
78 | /* get dai->name */ | 79 | /* get dai->name */ |
79 | ret = snd_soc_of_get_dai_name(np, &dai->name); | 80 | ret = snd_soc_of_get_dai_name(np, name); |
80 | if (ret < 0) | 81 | if (ret < 0) |
81 | goto parse_error; | 82 | goto parse_error; |
82 | 83 | ||
@@ -146,7 +147,8 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
146 | if (np) | 147 | if (np) |
147 | ret = asoc_simple_card_sub_parse_of(np, | 148 | ret = asoc_simple_card_sub_parse_of(np, |
148 | &info->cpu_dai, | 149 | &info->cpu_dai, |
149 | &dai_link->cpu_of_node); | 150 | &dai_link->cpu_of_node, |
151 | &dai_link->cpu_dai_name); | ||
150 | if (ret < 0) | 152 | if (ret < 0) |
151 | return ret; | 153 | return ret; |
152 | 154 | ||
@@ -156,19 +158,21 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
156 | if (np) | 158 | if (np) |
157 | ret = asoc_simple_card_sub_parse_of(np, | 159 | ret = asoc_simple_card_sub_parse_of(np, |
158 | &info->codec_dai, | 160 | &info->codec_dai, |
159 | &dai_link->codec_of_node); | 161 | &dai_link->codec_of_node, |
162 | &dai_link->codec_dai_name); | ||
160 | if (ret < 0) | 163 | if (ret < 0) |
161 | return ret; | 164 | return ret; |
162 | 165 | ||
163 | if (!info->cpu_dai.name || !info->codec_dai.name) | 166 | if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) |
164 | return -EINVAL; | 167 | return -EINVAL; |
165 | 168 | ||
166 | /* card name is created from CPU/CODEC dai name */ | 169 | /* card name is created from CPU/CODEC dai name */ |
167 | name = devm_kzalloc(dev, | 170 | name = devm_kzalloc(dev, |
168 | strlen(info->cpu_dai.name) + | 171 | strlen(dai_link->cpu_dai_name) + |
169 | strlen(info->codec_dai.name) + 2, | 172 | strlen(dai_link->codec_dai_name) + 2, |
170 | GFP_KERNEL); | 173 | GFP_KERNEL); |
171 | sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name); | 174 | sprintf(name, "%s-%s", dai_link->cpu_dai_name, |
175 | dai_link->codec_dai_name); | ||
172 | info->snd_card.name = name; | 176 | info->snd_card.name = name; |
173 | dai_link->name = dai_link->stream_name = name; | 177 | dai_link->name = dai_link->stream_name = name; |
174 | 178 | ||
@@ -178,11 +182,11 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
178 | dev_dbg(dev, "card-name : %s\n", name); | 182 | dev_dbg(dev, "card-name : %s\n", name); |
179 | dev_dbg(dev, "platform : %04x\n", info->daifmt); | 183 | dev_dbg(dev, "platform : %04x\n", info->daifmt); |
180 | dev_dbg(dev, "cpu : %s / %04x / %d\n", | 184 | dev_dbg(dev, "cpu : %s / %04x / %d\n", |
181 | info->cpu_dai.name, | 185 | dai_link->cpu_dai_name, |
182 | info->cpu_dai.fmt, | 186 | info->cpu_dai.fmt, |
183 | info->cpu_dai.sysclk); | 187 | info->cpu_dai.sysclk); |
184 | dev_dbg(dev, "codec : %s / %04x / %d\n", | 188 | dev_dbg(dev, "codec : %s / %04x / %d\n", |
185 | info->codec_dai.name, | 189 | dai_link->codec_dai_name, |
186 | info->codec_dai.fmt, | 190 | info->codec_dai.fmt, |
187 | info->codec_dai.sysclk); | 191 | info->codec_dai.sysclk); |
188 | 192 | ||
@@ -240,13 +244,13 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
240 | dai_link->stream_name = cinfo->name; | 244 | dai_link->stream_name = cinfo->name; |
241 | dai_link->platform_name = cinfo->platform; | 245 | dai_link->platform_name = cinfo->platform; |
242 | dai_link->codec_name = cinfo->codec; | 246 | dai_link->codec_name = cinfo->codec; |
247 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; | ||
248 | dai_link->codec_dai_name = cinfo->codec_dai.name; | ||
243 | } | 249 | } |
244 | 250 | ||
245 | /* | 251 | /* |
246 | * init snd_soc_dai_link | 252 | * init snd_soc_dai_link |
247 | */ | 253 | */ |
248 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; | ||
249 | dai_link->codec_dai_name = cinfo->codec_dai.name; | ||
250 | dai_link->init = asoc_simple_card_dai_init; | 254 | dai_link->init = asoc_simple_card_dai_init; |
251 | 255 | ||
252 | snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo); | 256 | snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo); |