Skip to content

Commit 368dee9

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

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

sound/soc/soc-core.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ static DEFINE_MUTEX(client_mutex);
5454
static LIST_HEAD(component_list);
5555
static LIST_HEAD(unbind_card_list);
5656

57+
#define for_each_component(component) \
58+
list_for_each_entry(component, &component_list, list)
59+
5760
/*
5861
* This is a timeout to do a DAPM powerdown after a stream is closed().
5962
* It can be used to eliminate pops between different playback streams, e.g.
@@ -176,7 +179,7 @@ static int dai_list_show(struct seq_file *m, void *v)
176179

177180
mutex_lock(&client_mutex);
178181

179-
list_for_each_entry(component, &component_list, list)
182+
for_each_component(component)
180183
list_for_each_entry(dai, &component->dai_list, list)
181184
seq_printf(m, "%s\n", dai->name);
182185

@@ -192,7 +195,7 @@ static int component_list_show(struct seq_file *m, void *v)
192195

193196
mutex_lock(&client_mutex);
194197

195-
list_for_each_entry(component, &component_list, list)
198+
for_each_component(component)
196199
seq_printf(m, "%s\n", component->name);
197200

198201
mutex_unlock(&client_mutex);
@@ -725,7 +728,7 @@ static struct snd_soc_component *soc_find_component(
725728

726729
lockdep_assert_held(&client_mutex);
727730

728-
list_for_each_entry(component, &component_list, list) {
731+
for_each_component(component) {
729732
if (of_node) {
730733
if (component->dev->of_node == of_node)
731734
return component;
@@ -775,7 +778,7 @@ struct snd_soc_dai *snd_soc_find_dai(
775778
lockdep_assert_held(&client_mutex);
776779

777780
/* Find CPU DAI from registered DAIs*/
778-
list_for_each_entry(component, &component_list, list) {
781+
for_each_component(component) {
779782
if (!snd_soc_is_matching_component(dlc, component))
780783
continue;
781784
list_for_each_entry(dai, &component->dai_list, list) {
@@ -902,7 +905,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
902905
rtd->codec_dai = codec_dais[0];
903906

904907
/* find one from the set of registered platforms */
905-
list_for_each_entry(component, &component_list, list) {
908+
for_each_component(component) {
906909
if (!snd_soc_is_matching_component(dai_link->platform,
907910
component))
908911
continue;
@@ -1874,7 +1877,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
18741877
struct snd_soc_dai_link *dai_link;
18751878
int i;
18761879

1877-
list_for_each_entry(component, &component_list, list) {
1880+
for_each_component(component) {
18781881

18791882
/* does this component override FEs ? */
18801883
if (!component->driver->ignore_machine)
@@ -3091,6 +3094,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)
30913094
snd_soc_component_setup_regmap(component);
30923095
}
30933096

3097+
/* see for_each_component */
30943098
list_add(&component->list, &component_list);
30953099
INIT_LIST_HEAD(&component->dobj_list);
30963100

@@ -3226,7 +3230,7 @@ static int __snd_soc_unregister_component(struct device *dev)
32263230
int found = 0;
32273231

32283232
mutex_lock(&client_mutex);
3229-
list_for_each_entry(component, &component_list, list) {
3233+
for_each_component(component) {
32303234
if (dev != component->dev)
32313235
continue;
32323236

@@ -3258,7 +3262,7 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
32583262

32593263
ret = NULL;
32603264
mutex_lock(&client_mutex);
3261-
list_for_each_entry(component, &component_list, list) {
3265+
for_each_component(component) {
32623266
if (dev != component->dev)
32633267
continue;
32643268

@@ -3658,7 +3662,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
36583662
*/
36593663
ret = -ENOTSUPP;
36603664
mutex_lock(&client_mutex);
3661-
list_for_each_entry(pos, &component_list, list) {
3665+
for_each_component(pos) {
36623666
struct device_node *component_of_node = pos->dev->of_node;
36633667

36643668
if (!component_of_node && pos->dev->parent)
@@ -3688,7 +3692,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,
36883692
int ret = -EPROBE_DEFER;
36893693

36903694
mutex_lock(&client_mutex);
3691-
list_for_each_entry(pos, &component_list, list) {
3695+
for_each_component(pos) {
36923696
component_of_node = pos->dev->of_node;
36933697
if (!component_of_node && pos->dev->parent)
36943698
component_of_node = pos->dev->parent->of_node;

0 commit comments

Comments
 (0)