Message ID | 87sgqwtd71.wl-kuninori.morimoto.gx@renesas.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: add soc-component.c | expand |
On Wed, 2019-07-24 at 10:51 +0900, Kuninori Morimoto wrote: > 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_hw_free() and use it. > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > include/sound/soc-component.h | 2 ++ > sound/soc/soc-component.c | 10 ++++++++++ > sound/soc/soc-pcm.c | 6 +----- > 3 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/include/sound/soc-component.h b/include/sound/soc- > component.h > index ac93189..9ec67a3 100644 > --- a/include/sound/soc-component.h > +++ b/include/sound/soc-component.h > @@ -332,5 +332,7 @@ int snd_soc_component_prepare(struct > snd_soc_component *component, > int snd_soc_component_hw_params(struct snd_soc_component *component, > struct snd_pcm_substream *substream, > struct snd_pcm_hw_params *params); > +int snd_soc_component_hw_free(struct snd_soc_component *component, > + struct snd_pcm_substream *substream); > > #endif /* __SOC_COMPONENT_H */ > diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c > index 249dac4..7246518 100644 > --- a/sound/soc/soc-component.c > +++ b/sound/soc/soc-component.c > @@ -326,3 +326,13 @@ int snd_soc_component_hw_params(struct > snd_soc_component *component, > > return 0; > } > + > +int snd_soc_component_hw_free(struct snd_soc_component *component, > + struct snd_pcm_substream *substream) > +{ > + if (component->driver->ops && > + component->driver->ops->hw_free) > + return component->driver->ops->hw_free(substream); > + > + return 0; > +} > diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c > index 26f73af..780a119 100644 > --- a/sound/soc/soc-pcm.c > +++ b/sound/soc/soc-pcm.c > @@ -843,11 +843,7 @@ static int soc_pcm_components_hw_free(struct > snd_pcm_substream *substream, > if (component == last) > break; > > - if (!component->driver->ops || > - !component->driver->ops->hw_free) > - continue; > - > - component->driver->ops->hw_free(substream); > + snd_soc_component_hw_free(component, substream); Morimoto-san, Just wondering why we dont care about the return value here. I see that the original code ignores the return value too but is it something that should be addressed? Thanks, Ranjani > } > > return 0;
Hi Ranjani > > @@ -843,11 +843,7 @@ static int soc_pcm_components_hw_free(struct > > snd_pcm_substream *substream, > > if (component == last) > > break; > > > > - if (!component->driver->ops || > > - !component->driver->ops->hw_free) > > - continue; > > - > > - component->driver->ops->hw_free(substream); > > + snd_soc_component_hw_free(component, substream); > Morimoto-san, > > Just wondering why we dont care about the return value here. I see that > the original code ignores the return value too but is it something that > should be addressed? Yes, indeed. Thank you for your feedback. I will fix up it at v2 Thank you for your help !! Best regards --- Kuninori Morimoto
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index ac93189..9ec67a3 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -332,5 +332,7 @@ int snd_soc_component_prepare(struct snd_soc_component *component, int snd_soc_component_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); +int snd_soc_component_hw_free(struct snd_soc_component *component, + struct snd_pcm_substream *substream); #endif /* __SOC_COMPONENT_H */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 249dac4..7246518 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -326,3 +326,13 @@ int snd_soc_component_hw_params(struct snd_soc_component *component, return 0; } + +int snd_soc_component_hw_free(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + if (component->driver->ops && + component->driver->ops->hw_free) + return component->driver->ops->hw_free(substream); + + return 0; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 26f73af..780a119 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -843,11 +843,7 @@ static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream, if (component == last) break; - if (!component->driver->ops || - !component->driver->ops->hw_free) - continue; - - component->driver->ops->hw_free(substream); + snd_soc_component_hw_free(component, substream); } return 0;