From: Kuninori Morimoto Subject: [PATCH 14/25] ASoC: soc-component: add snd_soc_component_pcm_new() Date: 24 Jul 2019 10:52:25 +0900 Message-ID: <87imrstd62.wl-kuninori.morimoto.gx@renesas.com> References: <8736iwurtc.wl-kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id DD061F80638 for ; Wed, 24 Jul 2019 03:52:26 +0200 (CEST) In-Reply-To: <8736iwurtc.wl-kuninori.morimoto.gx@renesas.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Mark Brown Cc: Linux-ALSA List-Id: alsa-devel@alsa-project.org From: Kuninori Morimoto Current ALSA SoC is directly using component->driver->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_pcm() and use it. Signed-off-by: Kuninori Morimoto --- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 9 +++++++++ sound/soc/soc-pcm.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 223b0ce..9e61a52 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -352,5 +352,7 @@ struct page *snd_soc_component_page(struct snd_soc_component *component, int snd_soc_component_mmap(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct vm_area_struct *vma); +int snd_soc_component_pcm_new(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd); #endif /* __SOC_COMPONENT_H */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 166a8c8..8f3679e 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -403,3 +403,12 @@ int snd_soc_component_mmap(struct snd_soc_component *component, return -ENOTSUPP; } + +int snd_soc_component_pcm_new(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd) +{ + if (component->driver->pcm_new) + return component->driver->pcm_new(rtd); + + return 0; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index c483db0..466802f 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -3089,10 +3089,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; - if (!component->driver->pcm_new) - continue; - - ret = component->driver->pcm_new(rtd); + ret = snd_soc_component_pcm_new(component, rtd); if (ret < 0) { dev_err(component->dev, "ASoC: pcm constructor failed: %d\n", -- 2.7.4