Skip to content

Commit 15a0c64

Browse files
morimotobroonie
authored andcommitted
ASoC: add for_each_component_dais() macro
To be more readable code, this patch adds new for_each_component_dais() 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>
1 parent 368dee9 commit 15a0c64

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

include/sound/soc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ struct snd_soc_component {
864864
#endif
865865
};
866866

867+
#define for_each_component_dais(component, dai)\
868+
list_for_each_entry(dai, &(component)->dai_list, list)
869+
#define for_each_component_dais_safe(component, dai, _dai)\
870+
list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
871+
867872
struct snd_soc_rtdcom_list {
868873
struct snd_soc_component *component;
869874
struct list_head list; /* rtd::component_list */

sound/soc/soc-core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static int dai_list_show(struct seq_file *m, void *v)
180180
mutex_lock(&client_mutex);
181181

182182
for_each_component(component)
183-
list_for_each_entry(dai, &component->dai_list, list)
183+
for_each_component_dais(component, dai)
184184
seq_printf(m, "%s\n", dai->name);
185185

186186
mutex_unlock(&client_mutex);
@@ -781,7 +781,7 @@ struct snd_soc_dai *snd_soc_find_dai(
781781
for_each_component(component) {
782782
if (!snd_soc_is_matching_component(dlc, component))
783783
continue;
784-
list_for_each_entry(dai, &component->dai_list, list) {
784+
for_each_component_dais(component, dai) {
785785
if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
786786
&& (!dai->driver->name
787787
|| strcmp(dai->driver->name, dlc->dai_name)))
@@ -1312,7 +1312,7 @@ static int soc_probe_component(struct snd_soc_card *card,
13121312
}
13131313
}
13141314

1315-
list_for_each_entry(dai, &component->dai_list, list) {
1315+
for_each_component_dais(component, dai) {
13161316
ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
13171317
if (ret != 0) {
13181318
dev_err(component->dev,
@@ -2842,7 +2842,7 @@ static void snd_soc_unregister_dais(struct snd_soc_component *component)
28422842
{
28432843
struct snd_soc_dai *dai, *_dai;
28442844

2845-
list_for_each_entry_safe(dai, _dai, &component->dai_list, list) {
2845+
for_each_component_dais_safe(component, dai, _dai) {
28462846
dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n",
28472847
dai->name);
28482848
list_del(&dai->list);
@@ -2894,6 +2894,7 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
28942894
if (!dai->driver->ops)
28952895
dai->driver->ops = &null_dai_ops;
28962896

2897+
/* see for_each_component_dais */
28972898
list_add_tail(&dai->list, &component->dai_list);
28982899
component->num_dai++;
28992900

@@ -3728,7 +3729,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,
37283729
ret = 0;
37293730

37303731
/* find target DAI */
3731-
list_for_each_entry(dai, &pos->dai_list, list) {
3732+
for_each_component_dais(pos, dai) {
37323733
if (id == 0)
37333734
break;
37343735
id--;

0 commit comments

Comments
 (0)