diff mbox series

[23/25] ASoC: soc-component: move snd_soc_component_seq_notifier()

Message ID 875znstd4h.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: add soc-component.c | expand

Commit Message

Kuninori Morimoto July 24, 2019, 1:53 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch moves snd_soc_component_seq_notifier() to soc-component.c
It will be used at soc-dapm.c :: dapm_seq_run(),
but no effect by this patch.

	static void dapm_seq_run(...)
	{
		...
=>		if (cur_dapm && cur_dapm->seq_notifier) {
			for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
				if (sort[i] == cur_sort)
=>					cur_dapm->seq_notifier(cur_dapm,
							       i,
							       cur_subseq);
		}
		...
	}

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

Comments

Charles Keepax July 24, 2019, 9:35 a.m. UTC | #1
On Wed, Jul 24, 2019 at 10:53:22AM +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> This patch moves snd_soc_component_seq_notifier() to soc-component.c
> It will be used at soc-dapm.c :: dapm_seq_run(),
> but no effect by this patch.
> 
> 	static void dapm_seq_run(...)
> 	{
> 		...
> =>		if (cur_dapm && cur_dapm->seq_notifier) {
> 			for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
> 				if (sort[i] == cur_sort)
> =>					cur_dapm->seq_notifier(cur_dapm,
> 							       i,
> 							       cur_subseq);
> 		}
> 		...
> 	}
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> +void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm,
> +				    enum snd_soc_dapm_type type, int subseq)
> +{
> +	struct snd_soc_component *component = dapm->component;
> +
> +	if (component->driver->seq_notifier)
> +		component->driver->seq_notifier(component, type, subseq);
> +}
> +
>  int snd_soc_component_enable_pin(struct snd_soc_component *component,
>  				 const char *pin)
>  {
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 573192d..84ded01 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
>  static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm,
>  	int event)
>  {
> @@ -2736,8 +2728,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
>  	dapm->bias_level = SND_SOC_BIAS_OFF;
>  	dapm->idle_bias_off = !driver->idle_bias_on;
>  	dapm->suspend_bias_off = driver->suspend_bias_off;
> -	if (driver->seq_notifier)
> -		dapm->seq_notifier = snd_soc_component_seq_notifier;
> +	dapm->seq_notifier = snd_soc_component_seq_notifier;

If we are updating this to always set a seq_notifier would it be
worth removing the NULL checks in soc-dapm.c? At the moment I
guess it will end up checking twice, DAPM checks if dapm->seq_notifier
is NULL but it never will be, then the helper checks if
driver->seq_notifier is NULL.

Thanks,
Charles
Kuninori Morimoto July 25, 2019, 1:54 a.m. UTC | #2
Hi Charles

> > @@ -2736,8 +2728,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
> >  	dapm->bias_level = SND_SOC_BIAS_OFF;
> >  	dapm->idle_bias_off = !driver->idle_bias_on;
> >  	dapm->suspend_bias_off = driver->suspend_bias_off;
> > -	if (driver->seq_notifier)
> > -		dapm->seq_notifier = snd_soc_component_seq_notifier;
> > +	dapm->seq_notifier = snd_soc_component_seq_notifier;
> 
> If we are updating this to always set a seq_notifier would it be
> worth removing the NULL checks in soc-dapm.c? At the moment I
> guess it will end up checking twice, DAPM checks if dapm->seq_notifier
> is NULL but it never will be, then the helper checks if
> driver->seq_notifier is NULL.

Yes, indeed.
I will double-check it, and will fix it at v2

Thank you for your help !!
Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 37b25cc..4711138 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -273,6 +273,10 @@  int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
 int snd_soc_component_set_jack(struct snd_soc_component *component,
 			       struct snd_soc_jack *jack, void *data);
 
+/* for dapm */
+void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm,
+				    enum snd_soc_dapm_type type, int subseq);
+
 #ifdef CONFIG_REGMAP
 void snd_soc_component_init_regmap(struct snd_soc_component *component,
 				   struct regmap *regmap);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 732f06a..e4e8fc4 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -52,6 +52,15 @@  int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_set_pll);
 
+void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm,
+				    enum snd_soc_dapm_type type, int subseq)
+{
+	struct snd_soc_component *component = dapm->component;
+
+	if (component->driver->seq_notifier)
+		component->driver->seq_notifier(component, type, subseq);
+}
+
 int snd_soc_component_enable_pin(struct snd_soc_component *component,
 				 const char *pin)
 {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 573192d..84ded01 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2692,14 +2692,6 @@  int snd_soc_register_dai(struct snd_soc_component *component,
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_dai);
 
-static void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm,
-	enum snd_soc_dapm_type type, int subseq)
-{
-	struct snd_soc_component *component = dapm->component;
-
-	component->driver->seq_notifier(component, type, subseq);
-}
-
 static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm,
 	int event)
 {
@@ -2736,8 +2728,7 @@  static int snd_soc_component_initialize(struct snd_soc_component *component,
 	dapm->bias_level = SND_SOC_BIAS_OFF;
 	dapm->idle_bias_off = !driver->idle_bias_on;
 	dapm->suspend_bias_off = driver->suspend_bias_off;
-	if (driver->seq_notifier)
-		dapm->seq_notifier = snd_soc_component_seq_notifier;
+	dapm->seq_notifier = snd_soc_component_seq_notifier;
 	if (driver->stream_event)
 		dapm->stream_event = snd_soc_component_stream_event;
 	if (driver->set_bias_level)