All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>, Lars-Peter <lars@metafoo.de>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>, Simon <horms@verge.net.au>
Subject: [PATCH 4/6] ASoC: add for_each_component{_safe}
Date: Mon, 19 Dec 2016 07:37:57 +0000	[thread overview]
Message-ID: <874m2074ls.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87a8bs74t5.wl%kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

To be more readable code, this patch adds new for_each_component
macro.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  5 +++++
 sound/soc/soc-core.c | 10 ++++------
 sound/soc/soc-pcm.c  |  5 ++---
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 4504920..5db4a90 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1190,6 +1190,11 @@ struct snd_soc_card {
 
 	void *drvdata;
 };
+#define	for_each_component(component, card) \
+	list_for_each_entry(component, &(card)->component_dev_list, card_list)
+#define	for_each_component_safe(component, _component, card)	\
+	list_for_each_entry_safe(component, _component, \
+				 &(card)->component_dev_list, card_list)
 
 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
 struct snd_soc_pcm_runtime {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 981443e..9f2b9e1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -703,7 +703,7 @@ int snd_soc_suspend(struct device *dev)
 	snd_soc_dapm_sync(&card->dapm);
 
 	/* suspend all COMPONENTs */
-	list_for_each_entry(component, &card->component_dev_list, card_list) {
+	for_each_component(component, card) {
 		struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
 
 		/* If there are paths active then the COMPONENT will be held with
@@ -794,7 +794,7 @@ static void soc_resume_deferred(struct work_struct *work)
 			cpu_dai->driver->resume(cpu_dai);
 	}
 
-	list_for_each_entry(component, &card->component_dev_list, card_list) {
+	for_each_component(component, card) {
 		if (component->suspended) {
 			if (component->resume)
 				component->resume(component);
@@ -1764,7 +1764,7 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)
 
 	for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
 		order++) {
-		list_for_each_entry(comp, &card->component_dev_list, card_list) {
+		for_each_component(comp, card) {
 			if (!comp->auxiliary)
 				continue;
 
@@ -1790,9 +1790,7 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
 
 	for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
 		order++) {
-		list_for_each_entry_safe(comp, _comp,
-			&card->component_dev_list, card_list) {
-
+		for_each_component_safe(comp, _comp, card) {
 			if (!comp->auxiliary)
 				continue;
 
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index dec0b20..ff31bf5 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2631,8 +2631,7 @@ static void soc_pcm_free(struct snd_pcm *pcm)
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
 	struct snd_soc_component *component;
 
-	list_for_each_entry(component, &rtd->card->component_dev_list,
-			    card_list) {
+	for_each_component(component, rtd->card) {
 		if (component->pcm_free)
 			component->pcm_free(pcm);
 	}
@@ -2753,7 +2752,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 	if (capture)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
 
-	list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
+	for_each_component(component, rtd->card) {
 		if (component->pcm_new) {
 			ret = component->pcm_new(rtd);
 			if (ret < 0) {
-- 
1.9.1

  parent reply	other threads:[~2016-12-19  7:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19  7:33 [PATCH 0/6] ASoC: platform cleanup Kuninori Morimoto
2016-12-19  7:36 ` [PATCH 1/6] ASoC: remove .delay from snd_soc_platform_driver Kuninori Morimoto
2017-01-09 20:01   ` Applied "ASoC: remove .delay from snd_soc_platform_driver" to the asoc tree Mark Brown
2016-12-19  7:37 ` [PATCH 2/6] ASoC: remove .bespoke_trigger from snd_soc_platform_driver Kuninori Morimoto
2017-01-09 20:01   ` Applied "ASoC: remove .bespoke_trigger from snd_soc_platform_driver" to the asoc tree Mark Brown
2016-12-19  7:37 ` [PATCH 3/6] ASoC: remove snd_soc_platform_trigger() Kuninori Morimoto
2017-01-09 20:01   ` Applied "ASoC: remove snd_soc_platform_trigger()" to the asoc tree Mark Brown
2016-12-19  7:37 ` Kuninori Morimoto [this message]
2017-01-09 20:01   ` Applied "ASoC: add for_each_component{_safe}" " Mark Brown
2017-01-10 12:13     ` Mark Brown
2017-01-11  6:46       ` Kuninori Morimoto
2016-12-19  7:38 ` [PATCH 5/6] ASoC: add Component level struct snd_compr_ops Kuninori Morimoto
2016-12-19 11:12   ` Charles Keepax
2016-12-20  1:59     ` Kuninori Morimoto
2016-12-20 10:02       ` Charles Keepax
2016-12-21  0:42         ` Kuninori Morimoto
2016-12-21  9:29           ` Charles Keepax
2016-12-21 23:45             ` Kuninori Morimoto
2016-12-19  7:38 ` [PATCH 6/6] ASoC: add Component level struct snd_pcm_ops Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874m2074ls.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=lars@metafoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.