[alsa-devel] [PATCH 07/11] ASoC: add for_each_component_all() macro
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Tue Sep 18 03:30:10 CEST 2018
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
To be more readable code, this patch adds
new for_each_component_all() macro, and replace existing code to it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
sound/soc/soc-core.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 673a694..eb33e7e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -54,6 +54,9 @@ static DEFINE_MUTEX(client_mutex);
static LIST_HEAD(component_list);
static LIST_HEAD(unbind_card_list);
+#define for_each_component_all(component) \
+ list_for_each_entry(component, &component_list, list)
+
/*
* This is a timeout to do a DAPM powerdown after a stream is closed().
* 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)
mutex_lock(&client_mutex);
- list_for_each_entry(component, &component_list, list)
+ for_each_component_all(component)
list_for_each_entry(dai, &component->dai_list, list)
seq_printf(m, "%s\n", dai->name);
@@ -192,7 +195,7 @@ static int component_list_show(struct seq_file *m, void *v)
mutex_lock(&client_mutex);
- list_for_each_entry(component, &component_list, list)
+ for_each_component_all(component)
seq_printf(m, "%s\n", component->name);
mutex_unlock(&client_mutex);
@@ -725,7 +728,7 @@ static struct snd_soc_component *soc_find_component(
lockdep_assert_held(&client_mutex);
- list_for_each_entry(component, &component_list, list) {
+ for_each_component_all(component) {
if (of_node) {
if (component->dev->of_node == of_node)
return component;
@@ -775,7 +778,7 @@ struct snd_soc_dai *snd_soc_find_dai(
lockdep_assert_held(&client_mutex);
/* Find CPU DAI from registered DAIs*/
- list_for_each_entry(component, &component_list, list) {
+ for_each_component_all(component) {
if (!snd_soc_is_matching_component(dlc, component))
continue;
list_for_each_entry(dai, &component->dai_list, list) {
@@ -902,7 +905,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
rtd->codec_dai = codec_dais[0];
/* find one from the set of registered platforms */
- list_for_each_entry(component, &component_list, list) {
+ for_each_component_all(component) {
if (!snd_soc_is_matching_component(dai_link->platform,
component))
continue;
@@ -1878,7 +1881,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
struct snd_soc_dai_link *dai_link;
int i;
- list_for_each_entry(component, &component_list, list) {
+ for_each_component_all(component) {
/* does this component override FEs ? */
if (!component->driver->ignore_machine)
@@ -3097,6 +3100,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)
snd_soc_component_setup_regmap(component);
}
+ /* see for_each_component_all */
list_add(&component->list, &component_list);
INIT_LIST_HEAD(&component->dobj_list);
@@ -3232,7 +3236,7 @@ static int __snd_soc_unregister_component(struct device *dev)
int found = 0;
mutex_lock(&client_mutex);
- list_for_each_entry(component, &component_list, list) {
+ for_each_component_all(component) {
if (dev != component->dev)
continue;
@@ -3264,7 +3268,7 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
ret = NULL;
mutex_lock(&client_mutex);
- list_for_each_entry(component, &component_list, list) {
+ for_each_component_all(component) {
if (dev != component->dev)
continue;
@@ -3664,7 +3668,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
*/
ret = -ENOTSUPP;
mutex_lock(&client_mutex);
- list_for_each_entry(pos, &component_list, list) {
+ for_each_component_all(pos) {
struct device_node *component_of_node = pos->dev->of_node;
if (!component_of_node && pos->dev->parent)
@@ -3694,7 +3698,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,
int ret = -EPROBE_DEFER;
mutex_lock(&client_mutex);
- list_for_each_entry(pos, &component_list, list) {
+ for_each_component_all(pos) {
component_of_node = pos->dev->of_node;
if (!component_of_node && pos->dev->parent)
component_of_node = pos->dev->parent->of_node;
--
2.7.4
More information about the Alsa-devel
mailing list