[05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare()
diff mbox series

Message ID 87367fzhwx.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series
  • ASoC: soc-component: collect component functions
Related show

Commit Message

Kuninori Morimoto June 1, 2020, 1:36 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

We have 2 type of component functions
snd_soc_component_xxx()     is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.

Now we can update snd_soc_component_prepare() to
snd_soc_pcm_component_prepare(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  3 +--
 sound/soc/soc-component.c     | 28 +++++++++++++++++-----------
 sound/soc/soc-pcm.c           | 13 +++++--------
 3 files changed, 23 insertions(+), 21 deletions(-)

Comments

Ranjani Sridharan June 1, 2020, 6:22 p.m. UTC | #1
On Mon, 2020-06-01 at 10:36 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> We have 2 type of component functions
> snd_soc_component_xxx()     is focusing to component itself,
> snd_soc_pcm_component_xxx() is focusing to rtd related component.
> 
> Now we can update snd_soc_component_prepare() to
> snd_soc_pcm_component_prepare(). This patch do it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  3 +--
>  sound/soc/soc-component.c     | 28 +++++++++++++++++-----------
>  sound/soc/soc-pcm.c           | 13 +++++--------
>  3 files changed, 23 insertions(+), 21 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index cb0d34fa77c6..fc287e910240 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -426,8 +426,6 @@ int snd_soc_component_open(struct
> snd_soc_component *component,
>  			   struct snd_pcm_substream *substream);
>  int snd_soc_component_close(struct snd_soc_component *component,
>  			    struct snd_pcm_substream *substream);
> -int snd_soc_component_prepare(struct snd_soc_component *component,
> -			      struct snd_pcm_substream *substream);
>  int snd_soc_component_hw_params(struct snd_soc_component *component,
>  				struct snd_pcm_substream *substream,
>  				struct snd_pcm_hw_params *params);
> @@ -460,5 +458,6 @@ int snd_soc_pcm_component_mmap(struct
> snd_pcm_substream *substream,
>  			       struct vm_area_struct *vma);
>  int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
>  void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
> +int snd_soc_pcm_component_prepare(struct snd_pcm_substream
> *substream);
>  
>  #endif /* __SOC_COMPONENT_H */
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 6d29c2de3b24..1bc155bc8e5e 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -275,17 +275,6 @@ int snd_soc_component_close(struct
> snd_soc_component *component,
>  	return soc_component_ret(component, ret);
>  }
>  
> -int snd_soc_component_prepare(struct snd_soc_component *component,
> -			      struct snd_pcm_substream *substream)
> -{
> -	int ret = 0;
> -
> -	if (component->driver->prepare)
> -		ret = component->driver->prepare(component, substream);
> -
> -	return soc_component_ret(component, ret);
> -}
> -
>  int snd_soc_component_hw_params(struct snd_soc_component *component,
>  				struct snd_pcm_substream *substream,
>  				struct snd_pcm_hw_params *params)
> @@ -569,3 +558,20 @@ void snd_soc_pcm_component_free(struct
> snd_soc_pcm_runtime *rtd)
>  		if (component->driver->pcm_destruct)
>  			component->driver->pcm_destruct(component, rtd-
> >pcm);
>  }
> +
> +int snd_soc_pcm_component_prepare(struct snd_pcm_substream
> *substream)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_component *component;
> +	int i, ret;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->prepare) {
> +			ret = component->driver->prepare(component,
> substream);
> +			if (ret < 0)
> +				return soc_component_ret(component,
> ret);
> +		}
> +	}
> +
> +	return 0;
> +}
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 276505fb9d50..e61e7a56d95e 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -850,7 +850,6 @@ static void codec2codec_close_delayed_work(struct
> snd_soc_pcm_runtime *rtd)
>  static int soc_pcm_prepare(struct snd_pcm_substream *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> -	struct snd_soc_component *component;
>  	struct snd_soc_dai *dai;
>  	int i, ret = 0;
>  
> @@ -860,13 +859,11 @@ static int soc_pcm_prepare(struct
> snd_pcm_substream *substream)
>  	if (ret < 0)
>  		goto out;
>  
> -	for_each_rtd_components(rtd, i, component) {
> -		ret = snd_soc_component_prepare(component, substream);
> -		if (ret < 0) {
> -			dev_err(component->dev,
> -				"ASoC: platform prepare error: %d\n",
> ret);
> -			goto out;
> -		}
> +	ret = snd_soc_pcm_component_prepare(substream);
> +	if (ret < 0) {
> +		dev_err(rtd->dev,
> +			"ASoC: platform prepare error: %d\n", ret);
Morimoto-san,
We should remove this. This will be a duplicate error message as
snd_soc_pcm_component_prepare() would already print the error before
returning.

Thanks,
Ranjani
Kuninori Morimoto June 1, 2020, 11:12 p.m. UTC | #2
Hi Ranjani

Thank you for reviewing

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > We have 2 type of component functions
> > snd_soc_component_xxx()     is focusing to component itself,
> > snd_soc_pcm_component_xxx() is focusing to rtd related component.
> > 
> > Now we can update snd_soc_component_prepare() to
> > snd_soc_pcm_component_prepare(). This patch do it.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
(snip)
> > -	for_each_rtd_components(rtd, i, component) {
> > -		ret = snd_soc_component_prepare(component, substream);
> > -		if (ret < 0) {
> > -			dev_err(component->dev,
> > -				"ASoC: platform prepare error: %d\n",
> > ret);
> > -			goto out;
> > -		}
> > +	ret = snd_soc_pcm_component_prepare(substream);
> > +	if (ret < 0) {
> > +		dev_err(rtd->dev,
> > +			"ASoC: platform prepare error: %d\n", ret);
> Morimoto-san,
> We should remove this. This will be a duplicate error message as
> snd_soc_pcm_component_prepare() would already print the error before
> returning.

Ohh, yes.
will fix in v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto

Patch
diff mbox series

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index cb0d34fa77c6..fc287e910240 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -426,8 +426,6 @@  int snd_soc_component_open(struct snd_soc_component *component,
 			   struct snd_pcm_substream *substream);
 int snd_soc_component_close(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream);
-int snd_soc_component_prepare(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream);
 int snd_soc_component_hw_params(struct snd_soc_component *component,
 				struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params);
@@ -460,5 +458,6 @@  int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
 			       struct vm_area_struct *vma);
 int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
 void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 6d29c2de3b24..1bc155bc8e5e 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -275,17 +275,6 @@  int snd_soc_component_close(struct snd_soc_component *component,
 	return soc_component_ret(component, ret);
 }
 
-int snd_soc_component_prepare(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-
-	if (component->driver->prepare)
-		ret = component->driver->prepare(component, substream);
-
-	return soc_component_ret(component, ret);
-}
-
 int snd_soc_component_hw_params(struct snd_soc_component *component,
 				struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params)
@@ -569,3 +558,20 @@  void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd)
 		if (component->driver->pcm_destruct)
 			component->driver->pcm_destruct(component, rtd->pcm);
 }
+
+int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->prepare) {
+			ret = component->driver->prepare(component, substream);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 276505fb9d50..e61e7a56d95e 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -850,7 +850,6 @@  static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
 static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_component *component;
 	struct snd_soc_dai *dai;
 	int i, ret = 0;
 
@@ -860,13 +859,11 @@  static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 	if (ret < 0)
 		goto out;
 
-	for_each_rtd_components(rtd, i, component) {
-		ret = snd_soc_component_prepare(component, substream);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"ASoC: platform prepare error: %d\n", ret);
-			goto out;
-		}
+	ret = snd_soc_pcm_component_prepare(substream);
+	if (ret < 0) {
+		dev_err(rtd->dev,
+			"ASoC: platform prepare error: %d\n", ret);
+		goto out;
 	}
 
 	ret = snd_soc_pcm_dai_prepare(substream);