summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-09-17 21:28:49 -0400
committerMark Brown <broonie@kernel.org>2018-09-20 13:18:34 -0400
commit7fe072b4df5d0cc832eb758c1eed243c145a2dfc (patch)
treeb3b33044d52db6935e7346540cd3ddbf1a3f0ab0
parent6d11b12879144da5f5aa08071a8a7f95f3b5a4e8 (diff)
ASoC: add for_each_card_prelinks() macro
To be more readable code, this patch adds new for_each_card_prelinks() macro, and replace existing code to it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--include/sound/soc.h4
-rw-r--r--sound/soc/fsl/pcm030-audio-fabric.c5
-rw-r--r--sound/soc/generic/simple-card-utils.c6
-rw-r--r--sound/soc/intel/boards/skl_hda_dsp_generic.c5
-rw-r--r--sound/soc/mediatek/mt2701/mt2701-cs42448.c13
-rw-r--r--sound/soc/mediatek/mt2701/mt2701-wm8960.c13
-rw-r--r--sound/soc/mediatek/mt6797/mt6797-mt6351.c13
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-max98090.c13
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c7
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c7
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-rt5650.c7
-rw-r--r--sound/soc/meson/axg-card.c3
-rw-r--r--sound/soc/qcom/apq8096.c7
-rw-r--r--sound/soc/qcom/sdm845.c7
-rw-r--r--sound/soc/samsung/tm2_wm5110.c13
-rw-r--r--sound/soc/soc-core.c16
16 files changed, 73 insertions, 66 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index ec1ae9f4feeb..f94b989e7a1a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1120,6 +1120,10 @@ struct snd_soc_card {
1120 1120
1121 void *drvdata; 1121 void *drvdata;
1122}; 1122};
1123#define for_each_card_prelinks(card, i, link) \
1124 for ((i) = 0; \
1125 ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
1126 (i)++)
1123 1127
1124/* SoC machine DAI configuration, glues a codec and cpu DAI together */ 1128/* SoC machine DAI configuration, glues a codec and cpu DAI together */
1125struct snd_soc_pcm_runtime { 1129struct snd_soc_pcm_runtime {
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index ec731223cab3..e339f36cea95 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -57,6 +57,7 @@ static int pcm030_fabric_probe(struct platform_device *op)
57 struct device_node *platform_np; 57 struct device_node *platform_np;
58 struct snd_soc_card *card = &pcm030_card; 58 struct snd_soc_card *card = &pcm030_card;
59 struct pcm030_audio_data *pdata; 59 struct pcm030_audio_data *pdata;
60 struct snd_soc_dai_link *dai_link;
60 int ret; 61 int ret;
61 int i; 62 int i;
62 63
@@ -78,8 +79,8 @@ static int pcm030_fabric_probe(struct platform_device *op)
78 return -ENODEV; 79 return -ENODEV;
79 } 80 }
80 81
81 for (i = 0; i < card->num_links; i++) 82 for_each_card_prelinks(card, i, dai_link)
82 card->dai_link[i].platform_of_node = platform_np; 83 dai_link->platform_of_node = platform_np;
83 84
84 ret = request_module("snd-soc-wm9712"); 85 ret = request_module("snd-soc-wm9712");
85 if (ret) 86 if (ret)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index b400dbf1f834..f34cc6cddfa2 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -404,11 +404,9 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_cpu);
404int asoc_simple_card_clean_reference(struct snd_soc_card *card) 404int asoc_simple_card_clean_reference(struct snd_soc_card *card)
405{ 405{
406 struct snd_soc_dai_link *dai_link; 406 struct snd_soc_dai_link *dai_link;
407 int num_links; 407 int i;
408 408
409 for (num_links = 0, dai_link = card->dai_link; 409 for_each_card_prelinks(card, i, dai_link) {
410 num_links < card->num_links;
411 num_links++, dai_link++) {
412 of_node_put(dai_link->cpu_of_node); 410 of_node_put(dai_link->cpu_of_node);
413 of_node_put(dai_link->codecs->of_node); 411 of_node_put(dai_link->codecs->of_node);
414 } 412 }
diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
index b213e9b47505..b415dd4c85f5 100644
--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
+++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
@@ -104,6 +104,7 @@ static struct snd_soc_card hda_soc_card = {
104static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata) 104static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata)
105{ 105{
106 struct snd_soc_card *card = &hda_soc_card; 106 struct snd_soc_card *card = &hda_soc_card;
107 struct snd_soc_dai_link *dai_link;
107 u32 codec_count, codec_mask; 108 u32 codec_count, codec_mask;
108 int i, num_links, num_route; 109 int i, num_links, num_route;
109 110
@@ -125,8 +126,8 @@ static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata)
125 card->num_links = num_links; 126 card->num_links = num_links;
126 card->num_dapm_routes = num_route; 127 card->num_dapm_routes = num_route;
127 128
128 for (i = 0; i < num_links; i++) 129 for_each_card_prelinks(card, i, dai_link)
129 skl_hda_be_dai_links[i].platform_name = pdata->platform; 130 dai_link->platform_name = pdata->platform;
130 131
131 return 0; 132 return 0;
132} 133}
diff --git a/sound/soc/mediatek/mt2701/mt2701-cs42448.c b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
index 666282b865a8..875f84691535 100644
--- a/sound/soc/mediatek/mt2701/mt2701-cs42448.c
+++ b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
@@ -299,6 +299,7 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
299 devm_kzalloc(&pdev->dev, sizeof(struct mt2701_cs42448_private), 299 devm_kzalloc(&pdev->dev, sizeof(struct mt2701_cs42448_private),
300 GFP_KERNEL); 300 GFP_KERNEL);
301 struct device *dev = &pdev->dev; 301 struct device *dev = &pdev->dev;
302 struct snd_soc_dai_link *dai_link;
302 303
303 if (!priv) 304 if (!priv)
304 return -ENOMEM; 305 return -ENOMEM;
@@ -309,10 +310,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
309 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); 310 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
310 return -EINVAL; 311 return -EINVAL;
311 } 312 }
312 for (i = 0; i < card->num_links; i++) { 313 for_each_card_prelinks(card, i, dai_link) {
313 if (mt2701_cs42448_dai_links[i].platform_name) 314 if (dai_links->platform_name)
314 continue; 315 continue;
315 mt2701_cs42448_dai_links[i].platform_of_node = platform_node; 316 dai_links->platform_of_node = platform_node;
316 } 317 }
317 318
318 card->dev = dev; 319 card->dev = dev;
@@ -324,10 +325,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
324 "Property 'audio-codec' missing or invalid\n"); 325 "Property 'audio-codec' missing or invalid\n");
325 return -EINVAL; 326 return -EINVAL;
326 } 327 }
327 for (i = 0; i < card->num_links; i++) { 328 for_each_card_prelinks(card, i, dai_link) {
328 if (mt2701_cs42448_dai_links[i].codec_name) 329 if (dai_links->codec_name)
329 continue; 330 continue;
330 mt2701_cs42448_dai_links[i].codec_of_node = codec_node; 331 dai_links->codec_of_node = codec_node;
331 } 332 }
332 333
333 codec_node_bt_mrg = of_parse_phandle(pdev->dev.of_node, 334 codec_node_bt_mrg = of_parse_phandle(pdev->dev.of_node,
diff --git a/sound/soc/mediatek/mt2701/mt2701-wm8960.c b/sound/soc/mediatek/mt2701/mt2701-wm8960.c
index e5d49e6e2f99..c67f62935e53 100644
--- a/sound/soc/mediatek/mt2701/mt2701-wm8960.c
+++ b/sound/soc/mediatek/mt2701/mt2701-wm8960.c
@@ -97,6 +97,7 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev)
97{ 97{
98 struct snd_soc_card *card = &mt2701_wm8960_card; 98 struct snd_soc_card *card = &mt2701_wm8960_card;
99 struct device_node *platform_node, *codec_node; 99 struct device_node *platform_node, *codec_node;
100 struct snd_soc_dai_link *dai_link;
100 int ret, i; 101 int ret, i;
101 102
102 platform_node = of_parse_phandle(pdev->dev.of_node, 103 platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -105,10 +106,10 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev)
105 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); 106 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
106 return -EINVAL; 107 return -EINVAL;
107 } 108 }
108 for (i = 0; i < card->num_links; i++) { 109 for_each_card_prelinks(card, i, dai_link) {
109 if (mt2701_wm8960_dai_links[i].platform_name) 110 if (dai_links->platform_name)
110 continue; 111 continue;
111 mt2701_wm8960_dai_links[i].platform_of_node = platform_node; 112 dai_links->platform_of_node = platform_node;
112 } 113 }
113 114
114 card->dev = &pdev->dev; 115 card->dev = &pdev->dev;
@@ -120,10 +121,10 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev)
120 "Property 'audio-codec' missing or invalid\n"); 121 "Property 'audio-codec' missing or invalid\n");
121 return -EINVAL; 122 return -EINVAL;
122 } 123 }
123 for (i = 0; i < card->num_links; i++) { 124 for_each_card_prelinks(card, i, dai_link) {
124 if (mt2701_wm8960_dai_links[i].codec_name) 125 if (dai_links->codec_name)
125 continue; 126 continue;
126 mt2701_wm8960_dai_links[i].codec_of_node = codec_node; 127 dai_links->codec_of_node = codec_node;
127 } 128 }
128 129
129 ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); 130 ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
diff --git a/sound/soc/mediatek/mt6797/mt6797-mt6351.c b/sound/soc/mediatek/mt6797/mt6797-mt6351.c
index 6e578e830e42..ff2e0ca4384e 100644
--- a/sound/soc/mediatek/mt6797/mt6797-mt6351.c
+++ b/sound/soc/mediatek/mt6797/mt6797-mt6351.c
@@ -158,6 +158,7 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)
158{ 158{
159 struct snd_soc_card *card = &mt6797_mt6351_card; 159 struct snd_soc_card *card = &mt6797_mt6351_card;
160 struct device_node *platform_node, *codec_node; 160 struct device_node *platform_node, *codec_node;
161 struct snd_soc_dai_link *dai_link;
161 int ret, i; 162 int ret, i;
162 163
163 card->dev = &pdev->dev; 164 card->dev = &pdev->dev;
@@ -168,10 +169,10 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)
168 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); 169 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
169 return -EINVAL; 170 return -EINVAL;
170 } 171 }
171 for (i = 0; i < card->num_links; i++) { 172 for_each_card_prelinks(card, i, dai_link) {
172 if (mt6797_mt6351_dai_links[i].platform_name) 173 if (dai_link->platform_name)
173 continue; 174 continue;
174 mt6797_mt6351_dai_links[i].platform_of_node = platform_node; 175 dai_links->platform_of_node = platform_node;
175 } 176 }
176 177
177 codec_node = of_parse_phandle(pdev->dev.of_node, 178 codec_node = of_parse_phandle(pdev->dev.of_node,
@@ -181,10 +182,10 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)
181 "Property 'audio-codec' missing or invalid\n"); 182 "Property 'audio-codec' missing or invalid\n");
182 return -EINVAL; 183 return -EINVAL;
183 } 184 }
184 for (i = 0; i < card->num_links; i++) { 185 for_each_card_prelinks(card, i, dai_link) {
185 if (mt6797_mt6351_dai_links[i].codec_name) 186 if (dai_links->codec_name)
186 continue; 187 continue;
187 mt6797_mt6351_dai_links[i].codec_of_node = codec_node; 188 dai_links->codec_of_node = codec_node;
188 } 189 }
189 190
190 ret = devm_snd_soc_register_card(&pdev->dev, card); 191 ret = devm_snd_soc_register_card(&pdev->dev, card);
diff --git a/sound/soc/mediatek/mt8173/mt8173-max98090.c b/sound/soc/mediatek/mt8173/mt8173-max98090.c
index 902d111016d6..4d6596d5cb07 100644
--- a/sound/soc/mediatek/mt8173/mt8173-max98090.c
+++ b/sound/soc/mediatek/mt8173/mt8173-max98090.c
@@ -137,6 +137,7 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)
137{ 137{
138 struct snd_soc_card *card = &mt8173_max98090_card; 138 struct snd_soc_card *card = &mt8173_max98090_card;
139 struct device_node *codec_node, *platform_node; 139 struct device_node *codec_node, *platform_node;
140 struct snd_soc_dai_link *dai_link;
140 int ret, i; 141 int ret, i;
141 142
142 platform_node = of_parse_phandle(pdev->dev.of_node, 143 platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -145,10 +146,10 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)
145 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); 146 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
146 return -EINVAL; 147 return -EINVAL;
147 } 148 }
148 for (i = 0; i < card->num_links; i++) { 149 for_each_card_prelinks(card, i, dai_link) {
149 if (mt8173_max98090_dais[i].platform_name) 150 if (dai_link->platform_name)
150 continue; 151 continue;
151 mt8173_max98090_dais[i].platform_of_node = platform_node; 152 dai_link->platform_of_node = platform_node;
152 } 153 }
153 154
154 codec_node = of_parse_phandle(pdev->dev.of_node, 155 codec_node = of_parse_phandle(pdev->dev.of_node,
@@ -158,10 +159,10 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)
158 "Property 'audio-codec' missing or invalid\n"); 159 "Property 'audio-codec' missing or invalid\n");
159 return -EINVAL; 160 return -EINVAL;
160 } 161 }
161 for (i = 0; i < card->num_links; i++) { 162 for_each_card_prelinks(card, i, dai_link) {
162 if (mt8173_max98090_dais[i].codec_name) 163 if (dai_link->codec_name)
163 continue; 164 continue;
164 mt8173_max98090_dais[i].codec_of_node = codec_node; 165 dai_link->codec_of_node = codec_node;
165 } 166 }
166 card->dev = &pdev->dev; 167 card->dev = &pdev->dev;
167 168
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c
index 5b4e90180827..da5b58ce791b 100644
--- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c
+++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c
@@ -178,6 +178,7 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev)
178{ 178{
179 struct snd_soc_card *card = &mt8173_rt5650_rt5514_card; 179 struct snd_soc_card *card = &mt8173_rt5650_rt5514_card;
180 struct device_node *platform_node; 180 struct device_node *platform_node;
181 struct snd_soc_dai_link *dai_link;
181 int i, ret; 182 int i, ret;
182 183
183 platform_node = of_parse_phandle(pdev->dev.of_node, 184 platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -187,10 +188,10 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev)
187 return -EINVAL; 188 return -EINVAL;
188 } 189 }
189 190
190 for (i = 0; i < card->num_links; i++) { 191 for_each_card_prelinks(card, i, dai_link) {
191 if (mt8173_rt5650_rt5514_dais[i].platform_name) 192 if (dai_link->platform_name)
192 continue; 193 continue;
193 mt8173_rt5650_rt5514_dais[i].platform_of_node = platform_node; 194 dai_link->platform_of_node = platform_node;
194 } 195 }
195 196
196 mt8173_rt5650_rt5514_codecs[0].of_node = 197 mt8173_rt5650_rt5514_codecs[0].of_node =
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
index 82675ed057de..d83cd039b413 100644
--- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
+++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
@@ -224,6 +224,7 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
224{ 224{
225 struct snd_soc_card *card = &mt8173_rt5650_rt5676_card; 225 struct snd_soc_card *card = &mt8173_rt5650_rt5676_card;
226 struct device_node *platform_node; 226 struct device_node *platform_node;
227 struct snd_soc_dai_link *dai_link;
227 int i, ret; 228 int i, ret;
228 229
229 platform_node = of_parse_phandle(pdev->dev.of_node, 230 platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -233,10 +234,10 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
233 return -EINVAL; 234 return -EINVAL;
234 } 235 }
235 236
236 for (i = 0; i < card->num_links; i++) { 237 for_each_card_prelinks(card, i, dai_link) {
237 if (mt8173_rt5650_rt5676_dais[i].platform_name) 238 if (dai_link->platform_name)
238 continue; 239 continue;
239 mt8173_rt5650_rt5676_dais[i].platform_of_node = platform_node; 240 dai_link->platform_of_node = platform_node;
240 } 241 }
241 242
242 mt8173_rt5650_rt5676_codecs[0].of_node = 243 mt8173_rt5650_rt5676_codecs[0].of_node =
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
index ef05fbc40c32..7edf250c8fb1 100644
--- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c
+++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
@@ -239,6 +239,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
239 struct device_node *platform_node; 239 struct device_node *platform_node;
240 struct device_node *np; 240 struct device_node *np;
241 const char *codec_capture_dai; 241 const char *codec_capture_dai;
242 struct snd_soc_dai_link *dai_link;
242 int i, ret; 243 int i, ret;
243 244
244 platform_node = of_parse_phandle(pdev->dev.of_node, 245 platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -248,10 +249,10 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
248 return -EINVAL; 249 return -EINVAL;
249 } 250 }
250 251
251 for (i = 0; i < card->num_links; i++) { 252 for_each_card_prelinks(card, i, dai_link) {
252 if (mt8173_rt5650_dais[i].platform_name) 253 if (dai_link->platform_name)
253 continue; 254 continue;
254 mt8173_rt5650_dais[i].platform_of_node = platform_node; 255 dai_link->platform_of_node = platform_node;
255 } 256 }
256 257
257 mt8173_rt5650_codecs[0].of_node = 258 mt8173_rt5650_codecs[0].of_node =
diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index 197e10a96e28..aa54d2c612c9 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -101,8 +101,7 @@ static void axg_card_clean_references(struct axg_card *priv)
101 int i, j; 101 int i, j;
102 102
103 if (card->dai_link) { 103 if (card->dai_link) {
104 for (i = 0; i < card->num_links; i++) { 104 for_each_card_prelinks(card, i, link) {
105 link = &card->dai_link[i];
106 of_node_put(link->cpu_of_node); 105 of_node_put(link->cpu_of_node);
107 for_each_link_codecs(link, j, codec) 106 for_each_link_codecs(link, j, codec)
108 of_node_put(codec->of_node); 107 of_node_put(codec->of_node);
diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
index 1543e85629f8..fb45f396ab4a 100644
--- a/sound/soc/qcom/apq8096.c
+++ b/sound/soc/qcom/apq8096.c
@@ -25,13 +25,12 @@ static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
25 25
26static void apq8096_add_be_ops(struct snd_soc_card *card) 26static void apq8096_add_be_ops(struct snd_soc_card *card)
27{ 27{
28 struct snd_soc_dai_link *link = card->dai_link; 28 struct snd_soc_dai_link *link;
29 int i, num_links = card->num_links; 29 int i;
30 30
31 for (i = 0; i < num_links; i++) { 31 for_each_card_prelinks(card, i, link) {
32 if (link->no_pcm == 1) 32 if (link->no_pcm == 1)
33 link->be_hw_params_fixup = apq8096_be_hw_params_fixup; 33 link->be_hw_params_fixup = apq8096_be_hw_params_fixup;
34 link++;
35 } 34 }
36} 35}
37 36
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 2a781d87ee65..9effbecc571f 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -195,15 +195,14 @@ static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
195 195
196static void sdm845_add_be_ops(struct snd_soc_card *card) 196static void sdm845_add_be_ops(struct snd_soc_card *card)
197{ 197{
198 struct snd_soc_dai_link *link = card->dai_link; 198 struct snd_soc_dai_link *link;
199 int i, num_links = card->num_links; 199 int i;
200 200
201 for (i = 0; i < num_links; i++) { 201 for_each_card_prelinks(card, i, link) {
202 if (link->no_pcm == 1) { 202 if (link->no_pcm == 1) {
203 link->ops = &sdm845_be_ops; 203 link->ops = &sdm845_be_ops;
204 link->be_hw_params_fixup = sdm845_be_hw_params_fixup; 204 link->be_hw_params_fixup = sdm845_be_hw_params_fixup;
205 } 205 }
206 link++;
207 } 206 }
208} 207}
209 208
diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c
index 43332c32d7e9..dc93941e01c3 100644
--- a/sound/soc/samsung/tm2_wm5110.c
+++ b/sound/soc/samsung/tm2_wm5110.c
@@ -491,6 +491,7 @@ static int tm2_probe(struct platform_device *pdev)
491 struct snd_soc_card *card = &tm2_card; 491 struct snd_soc_card *card = &tm2_card;
492 struct tm2_machine_priv *priv; 492 struct tm2_machine_priv *priv;
493 struct of_phandle_args args; 493 struct of_phandle_args args;
494 struct snd_soc_dai_link *dai_link;
494 int num_codecs, ret, i; 495 int num_codecs, ret, i;
495 496
496 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 497 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -558,18 +559,18 @@ static int tm2_probe(struct platform_device *pdev)
558 } 559 }
559 560
560 /* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */ 561 /* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */
561 for (i = 0; i < card->num_links; i++) { 562 for_each_card_prelinks(card, i, dai_link) {
562 unsigned int dai_index = 0; /* WM5110 */ 563 unsigned int dai_index = 0; /* WM5110 */
563 564
564 card->dai_link[i].cpu_name = NULL; 565 dai_link->cpu_name = NULL;
565 card->dai_link[i].platform_name = NULL; 566 dai_link->platform_name = NULL;
566 567
567 if (num_codecs > 1 && i == card->num_links - 1) 568 if (num_codecs > 1 && i == card->num_links - 1)
568 dai_index = 1; /* HDMI */ 569 dai_index = 1; /* HDMI */
569 570
570 card->dai_link[i].codec_of_node = codec_dai_node[dai_index]; 571 dai_link->codec_of_node = codec_dai_node[dai_index];
571 card->dai_link[i].cpu_of_node = cpu_dai_node[dai_index]; 572 dai_link->cpu_of_node = cpu_dai_node[dai_index];
572 card->dai_link[i].platform_of_node = cpu_dai_node[dai_index]; 573 dai_link->platform_of_node = cpu_dai_node[dai_index];
573 } 574 }
574 575
575 if (num_codecs > 1) { 576 if (num_codecs > 1) {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index da2b2a758b6d..532d8c59ed1e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1889,9 +1889,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
1889 continue; 1889 continue;
1890 1890
1891 /* machine matches, so override the rtd data */ 1891 /* machine matches, so override the rtd data */
1892 for (i = 0; i < card->num_links; i++) { 1892 for_each_card_prelinks(card, i, dai_link) {
1893
1894 dai_link = &card->dai_link[i];
1895 1893
1896 /* ignore this FE */ 1894 /* ignore this FE */
1897 if (dai_link->dynamic) { 1895 if (dai_link->dynamic) {
@@ -1955,8 +1953,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1955 soc_check_tplg_fes(card); 1953 soc_check_tplg_fes(card);
1956 1954
1957 /* bind DAIs */ 1955 /* bind DAIs */
1958 for (i = 0; i < card->num_links; i++) { 1956 for_each_card_prelinks(card, i, dai_link) {
1959 ret = soc_bind_dai_link(card, &card->dai_link[i]); 1957 ret = soc_bind_dai_link(card, dai_link);
1960 if (ret != 0) 1958 if (ret != 0)
1961 goto base_error; 1959 goto base_error;
1962 } 1960 }
@@ -1969,8 +1967,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1969 } 1967 }
1970 1968
1971 /* add predefined DAI links to the list */ 1969 /* add predefined DAI links to the list */
1972 for (i = 0; i < card->num_links; i++) 1970 for_each_card_prelinks(card, i, dai_link)
1973 snd_soc_add_dai_link(card, card->dai_link+i); 1971 snd_soc_add_dai_link(card, dai_link);
1974 1972
1975 /* card bind complete so register a sound card */ 1973 /* card bind complete so register a sound card */
1976 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, 1974 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
@@ -2714,12 +2712,12 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
2714int snd_soc_register_card(struct snd_soc_card *card) 2712int snd_soc_register_card(struct snd_soc_card *card)
2715{ 2713{
2716 int i, ret; 2714 int i, ret;
2715 struct snd_soc_dai_link *link;
2717 2716
2718 if (!card->name || !card->dev) 2717 if (!card->name || !card->dev)
2719 return -EINVAL; 2718 return -EINVAL;
2720 2719
2721 for (i = 0; i < card->num_links; i++) { 2720 for_each_card_prelinks(card, i, link) {
2722 struct snd_soc_dai_link *link = &card->dai_link[i];
2723 2721
2724 ret = soc_init_dai_link(card, link); 2722 ret = soc_init_dai_link(card, link);
2725 if (ret) { 2723 if (ret) {