Commit 98061fdb authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: add for_each_card_links() macro

To be more readable code, this patch adds
new for_each_card_links() macro, and replace existing code to it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7fe072b4
...@@ -1125,6 +1125,12 @@ struct snd_soc_card { ...@@ -1125,6 +1125,12 @@ struct snd_soc_card {
((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
(i)++) (i)++)
#define for_each_card_links(card, link) \
list_for_each_entry(dai_link, &(card)->dai_link_list, list)
#define for_each_card_links_safe(card, link, _link) \
list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list)
/* SoC machine DAI configuration, glues a codec and cpu DAI together */ /* SoC machine DAI configuration, glues a codec and cpu DAI together */
struct snd_soc_pcm_runtime { struct snd_soc_pcm_runtime {
struct device *dev; struct device *dev;
......
...@@ -816,7 +816,7 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, ...@@ -816,7 +816,7 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
lockdep_assert_held(&client_mutex); lockdep_assert_held(&client_mutex);
list_for_each_entry_safe(link, _link, &card->dai_link_list, list) { for_each_card_links_safe(card, link, _link) {
if (link->id != id) if (link->id != id)
continue; continue;
...@@ -1004,7 +1004,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) ...@@ -1004,7 +1004,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
soc_remove_link_components(card, rtd, order); soc_remove_link_components(card, rtd, order);
} }
list_for_each_entry_safe(link, _link, &card->dai_link_list, list) { for_each_card_links_safe(card, link, _link) {
if (link->dobj.type == SND_SOC_DOBJ_DAI_LINK) if (link->dobj.type == SND_SOC_DOBJ_DAI_LINK)
dev_warn(card->dev, "Topology forgot to remove link %s?\n", dev_warn(card->dev, "Topology forgot to remove link %s?\n",
link->name); link->name);
...@@ -1219,7 +1219,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, ...@@ -1219,7 +1219,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,
if (dai_link->dobj.type && card->remove_dai_link) if (dai_link->dobj.type && card->remove_dai_link)
card->remove_dai_link(card, dai_link); card->remove_dai_link(card, dai_link);
list_for_each_entry_safe(link, _link, &card->dai_link_list, list) { for_each_card_links_safe(card, link, _link) {
if (link == dai_link) { if (link == dai_link) {
list_del(&link->list); list_del(&link->list);
return; return;
...@@ -2033,7 +2033,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) ...@@ -2033,7 +2033,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
/* Find new DAI links added during probing components and bind them. /* Find new DAI links added during probing components and bind them.
* Components with topology may bring new DAIs and DAI links. * Components with topology may bring new DAIs and DAI links.
*/ */
list_for_each_entry(dai_link, &card->dai_link_list, list) { for_each_card_links(card, dai_link) {
if (soc_is_dai_link_bound(card, dai_link)) if (soc_is_dai_link_bound(card, dai_link))
continue; continue;
......
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