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 12/29] ASoC: soc-component: add snd_soc_component_trigger()
Date: 26 Jul 2019 13:50:29 +0900	[thread overview]
Message-ID: <878ssl5rn5.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->ops->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_trigger() and use it.

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

	- no change

 include/sound/soc-component.h |  3 +++
 sound/soc/soc-component.c     | 11 +++++++++++
 sound/soc/soc-pcm.c           |  6 +-----
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index fbcd911..302e27a 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -350,5 +350,8 @@ int snd_soc_component_hw_params(struct snd_soc_component *component,
 				struct snd_pcm_hw_params *params);
 int snd_soc_component_hw_free(struct snd_soc_component *component,
 			      struct snd_pcm_substream *substream);
+int snd_soc_component_trigger(struct snd_soc_component *component,
+			      struct snd_pcm_substream *substream,
+			      int cmd);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index e2bc34e..cf0d20a 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -336,3 +336,14 @@ int snd_soc_component_hw_free(struct snd_soc_component *component,
 
 	return 0;
 }
+
+int snd_soc_component_trigger(struct snd_soc_component *component,
+			      struct snd_pcm_substream *substream,
+			      int cmd)
+{
+	if (component->driver->ops &&
+	    component->driver->ops->trigger)
+		return component->driver->ops->trigger(substream, cmd);
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 24dc570..58f3bc5 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1055,11 +1055,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	for_each_rtdcom(rtd, rtdcom) {
 		component = rtdcom->component;
 
-		if (!component->driver->ops ||
-		    !component->driver->ops->trigger)
-			continue;
-
-		ret = component->driver->ops->trigger(substream, cmd);
+		ret = snd_soc_component_trigger(component, substream, cmd);
 		if (ret < 0)
 			return ret;
 	}
-- 
2.7.4

  parent reply	other threads:[~2019-07-26  4:50 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 ` Kuninori Morimoto [this message]
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_component_trigger()" " 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 ` [PATCH v2 29/29] ASoC: soc-component: add snd_soc_pcm_component_pcm_free() Kuninori Morimoto
2019-08-05 16:09   ` Applied "ASoC: soc-component: add snd_soc_pcm_component_pcm_free()" to the asoc tree 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=878ssl5rn5.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.