All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 8/9] ASoC: soc-dapm: add for_each_card_dapms() macro
Date: 09 Mar 2020 13:08:16 +0900	[thread overview]
Message-ID: <87sgiigogf.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <874kuyi33c.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_card_dapms() macro, and replace existing code to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  3 +++
 sound/soc/soc-dapm.c | 18 +++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5e1b4ef1543c..3aee33c8249e 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1117,6 +1117,9 @@ struct snd_soc_card {
 #define for_each_card_components(card, component)			\
 	list_for_each_entry(component, &(card)->component_dev_list, card_list)
 
+#define for_each_card_dapms(card, dapm)					\
+	list_for_each_entry(dapm, &card->dapm_list, list)
+
 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
 struct snd_soc_pcm_runtime {
 	struct device *dev;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7374829c6675..ac48303ea26d 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1716,9 +1716,8 @@ static void dapm_seq_run(struct snd_soc_card *card,
 					i, cur_subseq);
 	}
 
-	list_for_each_entry(d, &card->dapm_list, list) {
+	for_each_card_dapms(card, d)
 		soc_dapm_async_complete(d);
-	}
 }
 
 static void dapm_widget_update(struct snd_soc_card *card)
@@ -1949,7 +1948,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
 
 	trace_snd_soc_dapm_start(card);
 
-	list_for_each_entry(d, &card->dapm_list, list) {
+	for_each_card_dapms(card, d) {
 		if (dapm_idle_bias_off(d))
 			d->target_bias_level = SND_SOC_BIAS_OFF;
 		else
@@ -2013,10 +2012,10 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
 	 * they're not ground referenced.
 	 */
 	bias = SND_SOC_BIAS_OFF;
-	list_for_each_entry(d, &card->dapm_list, list)
+	for_each_card_dapms(card, d)
 		if (d->target_bias_level > bias)
 			bias = d->target_bias_level;
-	list_for_each_entry(d, &card->dapm_list, list)
+	for_each_card_dapms(card, d)
 		if (!dapm_idle_bias_off(d))
 			d->target_bias_level = bias;
 
@@ -2025,7 +2024,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
 	/* Run card bias changes at first */
 	dapm_pre_sequence_async(&card->dapm, 0);
 	/* Run other bias changes in parallel */
-	list_for_each_entry(d, &card->dapm_list, list) {
+	for_each_card_dapms(card, d) {
 		if (d != &card->dapm && d->bias_level != d->target_bias_level)
 			async_schedule_domain(dapm_pre_sequence_async, d,
 						&async_domain);
@@ -2049,7 +2048,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
 	dapm_seq_run(card, &up_list, event, true);
 
 	/* Run all the bias changes in parallel */
-	list_for_each_entry(d, &card->dapm_list, list) {
+	for_each_card_dapms(card, d) {
 		if (d != &card->dapm && d->bias_level != d->target_bias_level)
 			async_schedule_domain(dapm_post_sequence_async, d,
 						&async_domain);
@@ -2059,7 +2058,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
 	dapm_post_sequence_async(&card->dapm, 0);
 
 	/* do we need to notify any clients that DAPM event is complete */
-	list_for_each_entry(d, &card->dapm_list, list) {
+	for_each_card_dapms(card, d) {
 		if (!d->component)
 			continue;
 
@@ -4776,6 +4775,7 @@ void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm,
 	}
 
 	INIT_LIST_HEAD(&dapm->list);
+	/* see for_each_card_dapms */
 	list_add(&dapm->list, &card->dapm_list);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_init);
@@ -4822,7 +4822,7 @@ void snd_soc_dapm_shutdown(struct snd_soc_card *card)
 {
 	struct snd_soc_dapm_context *dapm;
 
-	list_for_each_entry(dapm, &card->dapm_list, list) {
+	for_each_card_dapms(card, dapm) {
 		if (dapm != &card->dapm) {
 			soc_dapm_shutdown_dapm(dapm);
 			if (dapm->bias_level == SND_SOC_BIAS_STANDBY)
-- 
2.17.1


  parent reply	other threads:[~2020-03-09  4:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09  4:06 [PATCH 0/9] ASoC: soc-pcm cleanup step6 Kuninori Morimoto
2020-03-09  4:07 ` [PATCH 1/9] ASoC: soc.h: add for_each_rtd_codecs/cpus_dai() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: soc.h: add for_each_rtd_codecs/cpus_dai() macro" to the asoc tree Mark Brown
2020-03-09  4:07 ` [PATCH 2/9] ASoC: Intel: use for_each_rtd_codecs/cpus_dai() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: Intel: use for_each_rtd_codecs/cpus_dai() macro" to the asoc tree Mark Brown
2020-03-09  4:07 ` [PATCH 3/9] ASoC: mediatek: use for_each_rtd_codecs/cpus_dai() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: mediatek: use for_each_rtd_codecs/cpus_dai() macro" to the asoc tree Mark Brown
2020-03-09  4:07 ` [PATCH 4/9] ASoC: meson: use for_each_rtd_codecs/cpus_dai() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: meson: use for_each_rtd_codecs/cpus_dai() macro" to the asoc tree Mark Brown
2020-03-09  4:07 ` [PATCH 5/9] ASoC: qcom: use for_each_rtd_codecs/cpus_dai() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: qcom: use for_each_rtd_codecs/cpus_dai() macro" to the asoc tree Mark Brown
2020-03-09  4:08 ` [PATCH 6/9] ASoC: soc: use for_each_rtd_codecs/cpus_dai() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: soc: use for_each_rtd_codecs/cpus_dai() macro" to the asoc tree Mark Brown
2020-03-09  4:08 ` [PATCH 7/9] ASoC: soc.h: remove non plural form for_each_xxx macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: soc.h: remove non plural form for_each_xxx macro" to the asoc tree Mark Brown
2020-03-09  4:08 ` Kuninori Morimoto [this message]
2020-03-10 13:51   ` Applied "ASoC: soc-dapm: add for_each_card_dapms() " Mark Brown
2020-03-09  4:08 ` [PATCH 9/9] ASoC: soc-dapm: add for_each_card_widgets() macro Kuninori Morimoto
2020-03-10 13:51   ` Applied "ASoC: soc-dapm: add for_each_card_widgets() macro" to the asoc tree Mark Brown
2020-03-09 17:00 ` [PATCH 0/9] ASoC: soc-pcm cleanup step6 Sridharan, Ranjani
2020-03-09 17:15   ` Pierre-Louis Bossart

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=87sgiigogf.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /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.