void *drvdata;
};
+#define for_each_card_prelinks(card, i, link) \
+ for ((i) = 0; \
+ ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
+ (i)++)
/* SoC machine DAI configuration, glues a codec and cpu DAI together */
struct snd_soc_pcm_runtime {
struct device_node *platform_np;
struct snd_soc_card *card = &pcm030_card;
struct pcm030_audio_data *pdata;
+ struct snd_soc_dai_link *dai_link;
int ret;
int i;
return -ENODEV;
}
- for (i = 0; i < card->num_links; i++)
- card->dai_link[i].platform_of_node = platform_np;
+ for_each_card_prelinks(card, i, dai_link)
+ dai_link->platform_of_node = platform_np;
ret = request_module("snd-soc-wm9712");
if (ret)
int asoc_simple_card_clean_reference(struct snd_soc_card *card)
{
struct snd_soc_dai_link *dai_link;
- int num_links;
+ int i;
- for (num_links = 0, dai_link = card->dai_link;
- num_links < card->num_links;
- num_links++, dai_link++) {
+ for_each_card_prelinks(card, i, dai_link) {
of_node_put(dai_link->cpu_of_node);
of_node_put(dai_link->codecs->of_node);
}
static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata)
{
struct snd_soc_card *card = &hda_soc_card;
+ struct snd_soc_dai_link *dai_link;
u32 codec_count, codec_mask;
int i, num_links, num_route;
card->num_links = num_links;
card->num_dapm_routes = num_route;
- for (i = 0; i < num_links; i++)
- skl_hda_be_dai_links[i].platform_name = pdata->platform;
+ for_each_card_prelinks(card, i, dai_link)
+ dai_link->platform_name = pdata->platform;
return 0;
}
devm_kzalloc(&pdev->dev, sizeof(struct mt2701_cs42448_private),
GFP_KERNEL);
struct device *dev = &pdev->dev;
+ struct snd_soc_dai_link *dai_link;
if (!priv)
return -ENOMEM;
dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt2701_cs42448_dai_links[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_links->platform_name)
continue;
- mt2701_cs42448_dai_links[i].platform_of_node = platform_node;
+ dai_links->platform_of_node = platform_node;
}
card->dev = dev;
"Property 'audio-codec' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt2701_cs42448_dai_links[i].codec_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_links->codec_name)
continue;
- mt2701_cs42448_dai_links[i].codec_of_node = codec_node;
+ dai_links->codec_of_node = codec_node;
}
codec_node_bt_mrg = of_parse_phandle(pdev->dev.of_node,
{
struct snd_soc_card *card = &mt2701_wm8960_card;
struct device_node *platform_node, *codec_node;
+ struct snd_soc_dai_link *dai_link;
int ret, i;
platform_node = of_parse_phandle(pdev->dev.of_node,
dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt2701_wm8960_dai_links[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_links->platform_name)
continue;
- mt2701_wm8960_dai_links[i].platform_of_node = platform_node;
+ dai_links->platform_of_node = platform_node;
}
card->dev = &pdev->dev;
"Property 'audio-codec' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt2701_wm8960_dai_links[i].codec_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_links->codec_name)
continue;
- mt2701_wm8960_dai_links[i].codec_of_node = codec_node;
+ dai_links->codec_of_node = codec_node;
}
ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
{
struct snd_soc_card *card = &mt6797_mt6351_card;
struct device_node *platform_node, *codec_node;
+ struct snd_soc_dai_link *dai_link;
int ret, i;
card->dev = &pdev->dev;
dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt6797_mt6351_dai_links[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->platform_name)
continue;
- mt6797_mt6351_dai_links[i].platform_of_node = platform_node;
+ dai_links->platform_of_node = platform_node;
}
codec_node = of_parse_phandle(pdev->dev.of_node,
"Property 'audio-codec' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt6797_mt6351_dai_links[i].codec_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_links->codec_name)
continue;
- mt6797_mt6351_dai_links[i].codec_of_node = codec_node;
+ dai_links->codec_of_node = codec_node;
}
ret = devm_snd_soc_register_card(&pdev->dev, card);
{
struct snd_soc_card *card = &mt8173_max98090_card;
struct device_node *codec_node, *platform_node;
+ struct snd_soc_dai_link *dai_link;
int ret, i;
platform_node = of_parse_phandle(pdev->dev.of_node,
dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt8173_max98090_dais[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->platform_name)
continue;
- mt8173_max98090_dais[i].platform_of_node = platform_node;
+ dai_link->platform_of_node = platform_node;
}
codec_node = of_parse_phandle(pdev->dev.of_node,
"Property 'audio-codec' missing or invalid\n");
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt8173_max98090_dais[i].codec_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->codec_name)
continue;
- mt8173_max98090_dais[i].codec_of_node = codec_node;
+ dai_link->codec_of_node = codec_node;
}
card->dev = &pdev->dev;
{
struct snd_soc_card *card = &mt8173_rt5650_rt5514_card;
struct device_node *platform_node;
+ struct snd_soc_dai_link *dai_link;
int i, ret;
platform_node = of_parse_phandle(pdev->dev.of_node,
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt8173_rt5650_rt5514_dais[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->platform_name)
continue;
- mt8173_rt5650_rt5514_dais[i].platform_of_node = platform_node;
+ dai_link->platform_of_node = platform_node;
}
mt8173_rt5650_rt5514_codecs[0].of_node =
{
struct snd_soc_card *card = &mt8173_rt5650_rt5676_card;
struct device_node *platform_node;
+ struct snd_soc_dai_link *dai_link;
int i, ret;
platform_node = of_parse_phandle(pdev->dev.of_node,
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt8173_rt5650_rt5676_dais[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->platform_name)
continue;
- mt8173_rt5650_rt5676_dais[i].platform_of_node = platform_node;
+ dai_link->platform_of_node = platform_node;
}
mt8173_rt5650_rt5676_codecs[0].of_node =
struct device_node *platform_node;
struct device_node *np;
const char *codec_capture_dai;
+ struct snd_soc_dai_link *dai_link;
int i, ret;
platform_node = of_parse_phandle(pdev->dev.of_node,
return -EINVAL;
}
- for (i = 0; i < card->num_links; i++) {
- if (mt8173_rt5650_dais[i].platform_name)
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->platform_name)
continue;
- mt8173_rt5650_dais[i].platform_of_node = platform_node;
+ dai_link->platform_of_node = platform_node;
}
mt8173_rt5650_codecs[0].of_node =
int i, j;
if (card->dai_link) {
- for (i = 0; i < card->num_links; i++) {
- link = &card->dai_link[i];
+ for_each_card_prelinks(card, i, link) {
of_node_put(link->cpu_of_node);
for_each_link_codecs(link, j, codec)
of_node_put(codec->of_node);
static void apq8096_add_be_ops(struct snd_soc_card *card)
{
- struct snd_soc_dai_link *link = card->dai_link;
- int i, num_links = card->num_links;
+ struct snd_soc_dai_link *link;
+ int i;
- for (i = 0; i < num_links; i++) {
+ for_each_card_prelinks(card, i, link) {
if (link->no_pcm == 1)
link->be_hw_params_fixup = apq8096_be_hw_params_fixup;
- link++;
}
}
static void sdm845_add_be_ops(struct snd_soc_card *card)
{
- struct snd_soc_dai_link *link = card->dai_link;
- int i, num_links = card->num_links;
+ struct snd_soc_dai_link *link;
+ int i;
- for (i = 0; i < num_links; i++) {
+ for_each_card_prelinks(card, i, link) {
if (link->no_pcm == 1) {
link->ops = &sdm845_be_ops;
link->be_hw_params_fixup = sdm845_be_hw_params_fixup;
}
- link++;
}
}
struct snd_soc_card *card = &tm2_card;
struct tm2_machine_priv *priv;
struct of_phandle_args args;
+ struct snd_soc_dai_link *dai_link;
int num_codecs, ret, i;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
}
/* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */
- for (i = 0; i < card->num_links; i++) {
+ for_each_card_prelinks(card, i, dai_link) {
unsigned int dai_index = 0; /* WM5110 */
- card->dai_link[i].cpu_name = NULL;
- card->dai_link[i].platform_name = NULL;
+ dai_link->cpu_name = NULL;
+ dai_link->platform_name = NULL;
if (num_codecs > 1 && i == card->num_links - 1)
dai_index = 1; /* HDMI */
- card->dai_link[i].codec_of_node = codec_dai_node[dai_index];
- card->dai_link[i].cpu_of_node = cpu_dai_node[dai_index];
- card->dai_link[i].platform_of_node = cpu_dai_node[dai_index];
+ dai_link->codec_of_node = codec_dai_node[dai_index];
+ dai_link->cpu_of_node = cpu_dai_node[dai_index];
+ dai_link->platform_of_node = cpu_dai_node[dai_index];
}
if (num_codecs > 1) {
continue;
/* machine matches, so override the rtd data */
- for (i = 0; i < card->num_links; i++) {
-
- dai_link = &card->dai_link[i];
+ for_each_card_prelinks(card, i, dai_link) {
/* ignore this FE */
if (dai_link->dynamic) {
soc_check_tplg_fes(card);
/* bind DAIs */
- for (i = 0; i < card->num_links; i++) {
- ret = soc_bind_dai_link(card, &card->dai_link[i]);
+ for_each_card_prelinks(card, i, dai_link) {
+ ret = soc_bind_dai_link(card, dai_link);
if (ret != 0)
goto base_error;
}
}
/* add predefined DAI links to the list */
- for (i = 0; i < card->num_links; i++)
- snd_soc_add_dai_link(card, card->dai_link+i);
+ for_each_card_prelinks(card, i, dai_link)
+ snd_soc_add_dai_link(card, dai_link);
/* card bind complete so register a sound card */
ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
int snd_soc_register_card(struct snd_soc_card *card)
{
int i, ret;
+ struct snd_soc_dai_link *link;
if (!card->name || !card->dev)
return -EINVAL;
- for (i = 0; i < card->num_links; i++) {
- struct snd_soc_dai_link *link = &card->dai_link[i];
+ for_each_card_prelinks(card, i, link) {
ret = soc_init_dai_link(card, link);
if (ret) {