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 v2 29/29] ASoC: soc-component: add snd_soc_pcm_component_pcm_free()
Date: 26 Jul 2019 13:52:12 +0900	[thread overview]
Message-ID: <87k1c54czu.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87pnlx5rq3.wl-kuninori.morimoto.gx@renesas.com>

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

Current ALSA SoC is directly using component->driver->xxx,
thus, the code nested deeply, and it makes code difficult to read,
and is not good for encapsulation.

We want to implement component related function at soc-component.c,
but, some of them need to care whole snd_soc_pcm_runtime (= rtd)
connected component.

Let's call component related function which need to care with
for_each_rtdcom() loop as snd_soc_pcm_component_xxx().
This patch adds new snd_soc_pcm_component_pcm_free() and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

	- care for_each_rtdcom() loop

 include/sound/soc-component.h |  1 +
 sound/soc/soc-component.c     | 14 ++++++++++++++
 sound/soc/soc-pcm.c           |  9 +--------
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index d3048ad..5d80b2e 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -382,5 +382,6 @@ struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
 int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
 			       struct vm_area_struct *vma);
 int snd_soc_pcm_component_new(struct snd_pcm *pcm);
+void snd_soc_pcm_component_free(struct snd_pcm *pcm);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index ff13d90..79ffc28 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -545,3 +545,17 @@ int snd_soc_pcm_component_new(struct snd_pcm *pcm)
 
 	return 0;
 }
+
+void snd_soc_pcm_component_free(struct snd_pcm *pcm)
+{
+	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
+	struct snd_soc_rtdcom_list *rtdcom;
+	struct snd_soc_component *component;
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		if (component->driver->pcm_free)
+			component->driver->pcm_free(pcm);
+	}
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index adee27f..a697d4d 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2795,17 +2795,10 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
 static void soc_pcm_private_free(struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	struct snd_soc_rtdcom_list *rtdcom;
-	struct snd_soc_component *component;
 
 	/* need to sync the delayed work before releasing resources */
 	flush_delayed_work(&rtd->delayed_work);
-	for_each_rtdcom(rtd, rtdcom) {
-		component = rtdcom->component;
-
-		if (component->driver->pcm_free)
-			component->driver->pcm_free(pcm);
-	}
+	snd_soc_pcm_component_free(pcm);
 }
 
 /* create a new pcm */
-- 
2.7.4

  parent reply	other threads:[~2019-07-26  4:52 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  4:48 [PATCH v2 00/29] ASoC: add soc-component.c Kuninori Morimoto
2019-07-26  4:49 ` [PATCH v2 01/29] ASoC: Intel: skl-pcm: disable skl_get_time_info Kuninori Morimoto
2019-08-05 15:45   ` Mark Brown
2019-08-05 16:06     ` Pierre-Louis Bossart
2019-08-06  0:00       ` Kuninori Morimoto
2019-07-26  4:49 ` [PATCH v2 02/29] ASoC: soc-pcm: remove soc_rtdcom_ack() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-pcm: remove soc_rtdcom_ack()" to the asoc tree Mark Brown
2019-07-26  4:49 ` [PATCH v2 03/29] ASoC: soc-pcm: remove soc_rtdcom_copy_kernel() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-pcm: remove soc_rtdcom_copy_kernel()" to the asoc tree Mark Brown
2019-07-26  4:49 ` [PATCH v2 04/29] ASoC: soc-pcm: remove soc_fill_silence() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-pcm: remove soc_fill_silence()" to the asoc tree Mark Brown
2019-07-26  4:49 ` [PATCH v2 05/29] ASoC: add soc-component.c Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: add soc-component.c" to the asoc tree Mark Brown
2019-07-26  4:49 ` [PATCH v2 06/29] ASoC: soc-component: add snd_soc_component_get/put() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-component: add snd_soc_component_get/put()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 07/29] ASoC: soc-component: add snd_soc_component_open() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-component: add snd_soc_component_open()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 08/29] ASoC: soc-component: add snd_soc_component_close() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-component: add snd_soc_component_close()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 09/29] ASoC: soc-component: add snd_soc_component_prepare() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-component: add snd_soc_component_prepare()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 10/29] ASoC: soc-component: add snd_soc_component_hw_params() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-component: add snd_soc_component_hw_params()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 11/29] ASoC: soc-component: add snd_soc_component_hw_free() Kuninori Morimoto
2019-08-05 16:10   ` Applied "ASoC: soc-component: add snd_soc_component_hw_free()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 12/29] ASoC: soc-component: add snd_soc_component_trigger() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_trigger()" to the asoc tree Mark Brown
2019-07-26  4:50 ` [PATCH v2 13/29] ASoC: soc-component: add snd_soc_component_suspend() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_suspend()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 14/29] ASoC: soc-component: add snd_soc_component_resume() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_resume()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 15/29] ASoC: soc-component: add snd_soc_component_is_suspended() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_is_suspended()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 16/29] ASoC: soc-component: add snd_soc_component_probe() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_probe()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 17/29] ASoC: soc-component: add snd_soc_component_remove() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_remove()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 18/29] ASoC: soc-component: add snd_soc_component_of_xlate_dai_id() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_of_xlate_dai_id()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 19/29] ASoC: soc-component: add snd_soc_component_of_xlate_dai_name() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_of_xlate_dai_name()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 20/29] ASoC: soc-component: move snd_soc_component_seq_notifier() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: move snd_soc_component_seq_notifier()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 21/29] ASoC: soc-component: move snd_soc_component_stream_event() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: move snd_soc_component_stream_event()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 22/29] ASoC: soc-component: move snd_soc_component_set_bias_level() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: move snd_soc_component_set_bias_level()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 23/29] ASoC: soc-component: add snd_soc_pcm_component_pointer() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_pointer()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 24/29] ASoC: soc-component: add snd_soc_pcm_component_ioctrl() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_ioctrl()" to the asoc tree Mark Brown
2019-07-26  4:51 ` [PATCH v2 25/29] ASoC: soc-component: add snd_soc_pcm_component_copy_user() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_copy_user()" to the asoc tree Mark Brown
2019-07-26  4:52 ` [PATCH v2 26/29] ASoC: soc-component: add snd_soc_pcm_component_page() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_page()" to the asoc tree Mark Brown
2019-07-26  4:52 ` [PATCH v2 27/29] ASoC: soc-component: add snd_soc_pcm_component_mmap() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_mmap()" to the asoc tree Mark Brown
2019-07-26  4:52 ` [PATCH v2 28/29] ASoC: soc-component: add snd_soc_pcm_component_pcm_new() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_pcm_new()" to the asoc tree Mark Brown
2019-07-26  4:52 ` Kuninori Morimoto [this message]
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_pcm_free()" " Mark Brown

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=87k1c54czu.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.