From patchwork Thu Jun 4 08:06:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 192513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18755C433E2 for ; Thu, 4 Jun 2020 08:08:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96FA1206C3 for ; Thu, 4 Jun 2020 08:08:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Lhz8A5PD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96FA1206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 19BF01682; Thu, 4 Jun 2020 10:07:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 19BF01682 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591258107; bh=hRe+XMzIPsPHjWIRvfVVzDgHFtPs0h0dLLFMTjZ05+A=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Lhz8A5PDFKsKHtCOs77rwJORmvn9kB/Jl3BgTtWR37kxYWH/8xqB8nnMlLENyokfW LejF0bBBggEQUNaqu+fnG6nAkowdvJNuhMfTGexTiFFa+Giz82fq8DNqwjiK1sYUQM F2/LDSMygPXPo6D9jiRNWRr/FsyZSGHpnKArj9RM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1AFE6F8029B; Thu, 4 Jun 2020 10:06:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 54CB8F802A1; Thu, 4 Jun 2020 10:06:31 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 19C81F8029B for ; Thu, 4 Jun 2020 10:06:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 19C81F8029B Date: 04 Jun 2020 17:06:22 +0900 X-IronPort-AV: E=Sophos;i="5.73,471,1583161200"; d="scan'208";a="48819258" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 04 Jun 2020 17:06:22 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9AA0F400A887; Thu, 4 Jun 2020 17:06:22 +0900 (JST) Message-ID: <87sgfbw8zl.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 02/12] ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> References: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto soc-component is handling snd_soc_component_xxx(). Move snd_soc_component_xxx_regmap() to it. Signed-off-by: Kuninori Morimoto --- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 50 +++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 50 ----------------------------------- 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 5663891148e3..481132141dc2 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -359,6 +359,7 @@ int snd_soc_component_stream_event(struct snd_soc_component *component, int snd_soc_component_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level); +void snd_soc_component_setup_regmap(struct snd_soc_component *component); #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 76f4b953563c..3c96a1adaa8b 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -302,6 +302,56 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component, return -ENOTSUPP; } +void snd_soc_component_setup_regmap(struct snd_soc_component *component) +{ + int val_bytes = regmap_get_val_bytes(component->regmap); + + /* Errors are legitimate for non-integer byte multiples */ + if (val_bytes > 0) + component->val_bytes = val_bytes; +} + +#ifdef CONFIG_REGMAP + +/** + * snd_soc_component_init_regmap() - Initialize regmap instance for the + * component + * @component: The component for which to initialize the regmap instance + * @regmap: The regmap instance that should be used by the component + * + * This function allows deferred assignment of the regmap instance that is + * associated with the component. Only use this if the regmap instance is not + * yet ready when the component is registered. The function must also be called + * before the first IO attempt of the component. + */ +void snd_soc_component_init_regmap(struct snd_soc_component *component, + struct regmap *regmap) +{ + component->regmap = regmap; + snd_soc_component_setup_regmap(component); +} +EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap); + +/** + * snd_soc_component_exit_regmap() - De-initialize regmap instance for the + * component + * @component: The component for which to de-initialize the regmap instance + * + * Calls regmap_exit() on the regmap instance associated to the component and + * removes the regmap instance from the component. + * + * This function should only be used if snd_soc_component_init_regmap() was used + * to initialize the regmap instance. + */ +void snd_soc_component_exit_regmap(struct snd_soc_component *component) +{ + regmap_exit(component->regmap); + component->regmap = NULL; +} +EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); + +#endif + int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b07eca2c6ccc..8e90426d2770 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2381,56 +2381,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, return 0; } -static void snd_soc_component_setup_regmap(struct snd_soc_component *component) -{ - int val_bytes = regmap_get_val_bytes(component->regmap); - - /* Errors are legitimate for non-integer byte multiples */ - if (val_bytes > 0) - component->val_bytes = val_bytes; -} - -#ifdef CONFIG_REGMAP - -/** - * snd_soc_component_init_regmap() - Initialize regmap instance for the - * component - * @component: The component for which to initialize the regmap instance - * @regmap: The regmap instance that should be used by the component - * - * This function allows deferred assignment of the regmap instance that is - * associated with the component. Only use this if the regmap instance is not - * yet ready when the component is registered. The function must also be called - * before the first IO attempt of the component. - */ -void snd_soc_component_init_regmap(struct snd_soc_component *component, - struct regmap *regmap) -{ - component->regmap = regmap; - snd_soc_component_setup_regmap(component); -} -EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap); - -/** - * snd_soc_component_exit_regmap() - De-initialize regmap instance for the - * component - * @component: The component for which to de-initialize the regmap instance - * - * Calls regmap_exit() on the regmap instance associated to the component and - * removes the regmap instance from the component. - * - * This function should only be used if snd_soc_component_init_regmap() was used - * to initialize the regmap instance. - */ -void snd_soc_component_exit_regmap(struct snd_soc_component *component) -{ - regmap_exit(component->regmap); - component->regmap = NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); - -#endif - #define ENDIANNESS_MAP(name) \ (SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE) static u64 endianness_format_map[] = { From patchwork Thu Jun 4 08:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 192512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC6B9C433DF for ; Thu, 4 Jun 2020 08:09:26 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73527206C3 for ; Thu, 4 Jun 2020 08:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="N+bu9+W9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73527206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0BCF9165D; Thu, 4 Jun 2020 10:08:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0BCF9165D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591258165; bh=2jwzbsH5ddZDYWCZwHDNdXB657sw5wTQUhVo6GAN9fs=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=N+bu9+W9N7mFCY9j+lMqJP/OGZemh9bcEPtc2rvf0ssbauPbbjRzFfpPMR3dL+qR6 eREnQHbku351U67kCqJzpOYgeCm6wnD2q5Lj5qw4gwQVL/IAysQXAnuRTRI8AsJtJJ h8bMZ7nyPmLrENHsf/WUoloJI8o0VcDQvRIdLD8U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 05DF2F8023F; Thu, 4 Jun 2020 10:06:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 57330F802BD; Thu, 4 Jun 2020 10:06:50 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 1CD9AF8023F for ; Thu, 4 Jun 2020 10:06:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1CD9AF8023F Date: 04 Jun 2020 17:06:41 +0900 X-IronPort-AV: E=Sophos;i="5.73,471,1583161200"; d="scan'208";a="48819279" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 04 Jun 2020 17:06:41 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id DF7F4400A887; Thu, 4 Jun 2020 17:06:41 +0900 (JST) Message-ID: <87pnafw8z2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 04/12] ASoC: soc-component: add soc_component_err() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> References: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto At soc-component.c, it is good idea to indicate error function and its component name if there was error. This patch adds soc_component_err() for it. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-component.c | 162 +++++++++++++++++++++++++++----------- 1 file changed, 116 insertions(+), 46 deletions(-) diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 5bf2e71d3d83..6d29c2de3b24 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -8,6 +8,28 @@ #include #include +#define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret) +static inline int _soc_component_ret(struct snd_soc_component *component, + const char *func, int ret) +{ + /* Positive/Zero values are not errors */ + if (ret >= 0) + return ret; + + /* Negative values might be errors */ + switch (ret) { + case -EPROBE_DEFER: + case -ENOTSUPP: + break; + default: + dev_err(component->dev, + "ASoC: error at %s on %s: %d\n", + func, component->name, ret); + } + + return ret; +} + int snd_soc_component_initialize(struct snd_soc_component *component, const struct snd_soc_component_driver *driver, struct device *dev, const char *name) @@ -38,11 +60,13 @@ int snd_soc_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { + int ret = -ENOTSUPP; + if (component->driver->set_sysclk) - return component->driver->set_sysclk(component, clk_id, source, + ret = component->driver->set_sysclk(component, clk_id, source, freq, dir); - return -ENOTSUPP; + return soc_component_ret(component, ret); } EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk); @@ -60,11 +84,13 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { + int ret = -EINVAL; + if (component->driver->set_pll) - return component->driver->set_pll(component, pll_id, source, + ret = component->driver->set_pll(component, pll_id, source, freq_in, freq_out); - return -EINVAL; + return soc_component_ret(component, ret); } EXPORT_SYMBOL_GPL(snd_soc_component_set_pll); @@ -78,19 +104,23 @@ void snd_soc_component_seq_notifier(struct snd_soc_component *component, int snd_soc_component_stream_event(struct snd_soc_component *component, int event) { + int ret = 0; + if (component->driver->stream_event) - return component->driver->stream_event(component, event); + ret = component->driver->stream_event(component, event); - return 0; + return soc_component_ret(component, ret); } int snd_soc_component_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + int ret = 0; + if (component->driver->set_bias_level) - return component->driver->set_bias_level(component, level); + ret = component->driver->set_bias_level(component, level); - return 0; + return soc_component_ret(component, ret); } static int soc_component_pin(struct snd_soc_component *component, @@ -103,17 +133,21 @@ static int soc_component_pin(struct snd_soc_component *component, char *full_name; int ret; - if (!component->name_prefix) - return pin_func(dapm, pin); + if (!component->name_prefix) { + ret = pin_func(dapm, pin); + goto end; + } full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin); - if (!full_name) - return -ENOMEM; + if (!full_name) { + ret = -ENOMEM; + goto end; + } ret = pin_func(dapm, full_name); kfree(full_name); - - return ret; +end: + return soc_component_ret(component, ret); } int snd_soc_component_enable_pin(struct snd_soc_component *component, @@ -191,21 +225,25 @@ EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked); int snd_soc_component_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { + int ret = -ENOTSUPP; + if (component->driver->set_jack) - return component->driver->set_jack(component, jack, data); + ret = component->driver->set_jack(component, jack, data); - return -ENOTSUPP; + return soc_component_ret(component, ret); } EXPORT_SYMBOL_GPL(snd_soc_component_set_jack); int snd_soc_component_module_get(struct snd_soc_component *component, int upon_open) { + int ret = 0; + if (component->driver->module_get_upon_open == !!upon_open && !try_module_get(component->dev->driver->owner)) - return -ENODEV; + ret = -ENODEV; - return 0; + return soc_component_ret(component, ret); } void snd_soc_component_module_put(struct snd_soc_component *component, @@ -218,52 +256,70 @@ void snd_soc_component_module_put(struct snd_soc_component *component, int snd_soc_component_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { + int ret = 0; + if (component->driver->open) - return component->driver->open(component, substream); - return 0; + ret = component->driver->open(component, substream); + + return soc_component_ret(component, ret); } int snd_soc_component_close(struct snd_soc_component *component, struct snd_pcm_substream *substream) { + int ret = 0; + if (component->driver->close) - return component->driver->close(component, substream); - return 0; + ret = component->driver->close(component, substream); + + 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) - return component->driver->prepare(component, substream); - return 0; + 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) { + int ret = 0; + if (component->driver->hw_params) - return component->driver->hw_params(component, - substream, params); - return 0; + ret = component->driver->hw_params(component, + substream, params); + + return soc_component_ret(component, ret); } int snd_soc_component_hw_free(struct snd_soc_component *component, struct snd_pcm_substream *substream) { + int ret = 0; + if (component->driver->hw_free) - return component->driver->hw_free(component, substream); - return 0; + ret = component->driver->hw_free(component, substream); + + return soc_component_ret(component, ret); } int snd_soc_component_trigger(struct snd_soc_component *component, struct snd_pcm_substream *substream, int cmd) { + int ret = 0; + if (component->driver->trigger) - return component->driver->trigger(component, substream, cmd); - return 0; + ret = component->driver->trigger(component, substream, cmd); + + return soc_component_ret(component, ret); } void snd_soc_component_suspend(struct snd_soc_component *component) @@ -287,10 +343,12 @@ int snd_soc_component_is_suspended(struct snd_soc_component *component) int snd_soc_component_probe(struct snd_soc_component *component) { + int ret = 0; + if (component->driver->probe) - return component->driver->probe(component); + ret = component->driver->probe(component); - return 0; + return soc_component_ret(component, ret); } void snd_soc_component_remove(struct snd_soc_component *component) @@ -302,20 +360,25 @@ void snd_soc_component_remove(struct snd_soc_component *component) int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component, struct device_node *ep) { + int ret = -ENOTSUPP; + if (component->driver->of_xlate_dai_id) - return component->driver->of_xlate_dai_id(component, ep); + ret = component->driver->of_xlate_dai_id(component, ep); - return -ENOTSUPP; + return soc_component_ret(component, ret); } int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component, struct of_phandle_args *args, const char **dai_name) { + int ret = -ENOTSUPP; + if (component->driver->of_xlate_dai_name) - return component->driver->of_xlate_dai_name(component, - args, dai_name); - return -ENOTSUPP; + ret = component->driver->of_xlate_dai_name(component, + args, dai_name); + + return soc_component_ret(component, ret); } void snd_soc_component_setup_regmap(struct snd_soc_component *component) @@ -392,8 +455,10 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream, /* FIXME: use 1st ioctl */ for_each_rtd_components(rtd, i, component) if (component->driver->ioctl) - return component->driver->ioctl(component, substream, - cmd, arg); + return soc_component_ret( + component, + component->driver->ioctl(component, + substream, cmd, arg)); return snd_pcm_lib_ioctl(substream, cmd, arg); } @@ -409,7 +474,7 @@ int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream) ret = component->driver->sync_stop(component, substream); if (ret < 0) - return ret; + soc_component_ret(component, ret); } } @@ -427,8 +492,11 @@ int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream, /* FIXME. it returns 1st copy now */ for_each_rtd_components(rtd, i, component) if (component->driver->copy_user) - return component->driver->copy_user( - component, substream, channel, pos, buf, bytes); + return soc_component_ret( + component, + component->driver->copy_user( + component, substream, channel, + pos, buf, bytes)); return -EINVAL; } @@ -464,8 +532,10 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream, /* FIXME. it returns 1st mmap now */ for_each_rtd_components(rtd, i, component) if (component->driver->mmap) - return component->driver->mmap(component, - substream, vma); + soc_component_ret( + component, + component->driver->mmap(component, + substream, vma)); return -EINVAL; } @@ -480,7 +550,7 @@ int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd) if (component->driver->pcm_construct) { ret = component->driver->pcm_construct(component, rtd); if (ret < 0) - return ret; + soc_component_ret(component, ret); } } From patchwork Thu Jun 4 08:07:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 192511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C29ADC433DF for ; Thu, 4 Jun 2020 08:10:56 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 485CF206C3 for ; Thu, 4 Jun 2020 08:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="fxCqJa8p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 485CF206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CF3F3167F; Thu, 4 Jun 2020 10:10:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CF3F3167F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591258254; bh=q+9pbo6Ysu6B6FuaGvLb8iYxYFDqeGe3JHZYZqG+5gs=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fxCqJa8p3f+KsIXc3k2ZO89s5yKOxTqIksnHSIDGM2YZ1IW6lU7fSQgCH1IG1lnhG /oLm9WS1X6EqCVR9dlXiT2uOUFMS4SdmzTgPn18Q+xvXuagxHvnnUDybq7hz7WOkWW f0/TYMvcyxeoOnozWamQSmBU9XWykQ4Vi2ySI/Hc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 265A3F802E7; Thu, 4 Jun 2020 10:07:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 53DB3F802E8; Thu, 4 Jun 2020 10:07:19 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 4ABF9F802E0 for ; Thu, 4 Jun 2020 10:07:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4ABF9F802E0 Date: 04 Jun 2020 17:07:11 +0900 X-IronPort-AV: E=Sophos;i="5.73,471,1583161200"; d="scan'208";a="48819310" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 04 Jun 2020 17:07:11 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 1647A41D4306; Thu, 4 Jun 2020 17:07:11 +0900 (JST) Message-ID: <87mu5jw8y8.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 06/12] ASoC: soc-component: add snd_soc_pcm_component_hw_params() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> References: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto 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_hw_params() to snd_soc_pcm_component_hw_params(). This patch do it. Signed-off-by: Kuninori Morimoto --- include/sound/soc-component.h | 6 +++--- sound/soc/soc-component.c | 36 ++++++++++++++++++++++------------- sound/soc/soc-pcm.c | 13 +++---------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index fc287e910240..a2898bdd0a3c 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -426,9 +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_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); int snd_soc_component_trigger(struct snd_soc_component *component, @@ -459,5 +456,8 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream, 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); +int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_component **last); #endif /* __SOC_COMPONENT_H */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 1bc155bc8e5e..56341968fe6d 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -275,19 +275,6 @@ int snd_soc_component_close(struct snd_soc_component *component, 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) -{ - int ret = 0; - - if (component->driver->hw_params) - ret = component->driver->hw_params(component, - substream, params); - - return soc_component_ret(component, ret); -} - int snd_soc_component_hw_free(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -575,3 +562,26 @@ int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream) return 0; } + +int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_component **last) +{ + 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->hw_params) { + ret = component->driver->hw_params(component, + substream, params); + if (ret < 0) { + *last = component; + return soc_component_ret(component, ret); + } + } + } + + *last = NULL; + return 0; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index e8911b83600b..d1e429699c6a 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1009,16 +1009,9 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, snd_soc_dapm_update_dai(substream, params, cpu_dai); } - for_each_rtd_components(rtd, i, component) { - ret = snd_soc_component_hw_params(component, substream, params); - if (ret < 0) { - dev_err(component->dev, - "ASoC: %s hw params failed: %d\n", - component->name, ret); - goto component_err; - } - } - component = NULL; + ret = snd_soc_pcm_component_hw_params(substream, params, &component); + if (ret < 0) + goto component_err; out: mutex_unlock(&rtd->card->pcm_mutex); From patchwork Thu Jun 4 08:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 192510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ECABC433E0 for ; Thu, 4 Jun 2020 08:11:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF5EE206C3 for ; Thu, 4 Jun 2020 08:11:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="YHVEphr9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF5EE206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2CFFC1663; Thu, 4 Jun 2020 10:10:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2CFFC1663 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591258309; bh=3E+CrT1DMHDn2CkkqLOl08Kp4veNncx3EdFXgG/qLIA=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YHVEphr9OrtYPgxyxDlGDdp6xsPVTtderGuVyiOGvZjLXc+pSbhYaCI1hAGPGQxsP 7KK+5OtTNdOZn4CndAisAIXlngn4SVD0Iepn5qoNX3x6+hM347ZSgaNEaiZUZp7jSE Uro/pa/u2rhnBLaP2Ks0MxhiAwjGzXHCQ5TyMvFw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CB494F80274; Thu, 4 Jun 2020 10:07:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 61040F80279; Thu, 4 Jun 2020 10:07:49 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 297AEF80108 for ; Thu, 4 Jun 2020 10:07:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 297AEF80108 Date: 04 Jun 2020 17:07:40 +0900 X-IronPort-AV: E=Sophos;i="5.73,471,1583161200"; d="scan'208";a="48819377" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 04 Jun 2020 17:07:40 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4C25F41D432D; Thu, 4 Jun 2020 17:07:40 +0900 (JST) Message-ID: <87k10nw8xf.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 08/12] ASoC: soc-component: add snd_soc_pcm_component_trigger() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> References: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto 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_trigger() to snd_soc_pcm_component_trigger(). This patch do it. Signed-off-by: Kuninori Morimoto --- include/sound/soc-component.h | 5 ++--- sound/soc/soc-component.c | 30 ++++++++++++++++++------------ sound/soc/soc-pcm.c | 24 ++++++++---------------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index d2f62d529559..bb26d55a9289 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -426,9 +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_trigger(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - int cmd); void snd_soc_component_suspend(struct snd_soc_component *component); void snd_soc_component_resume(struct snd_soc_component *component); int snd_soc_component_is_suspended(struct snd_soc_component *component); @@ -459,5 +456,7 @@ int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component **last); void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream, struct snd_soc_component *last); +int snd_soc_pcm_component_trigger(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 380f6459b5cb..150b02be0219 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -275,18 +275,6 @@ int snd_soc_component_close(struct snd_soc_component *component, return soc_component_ret(component, ret); } -int snd_soc_component_trigger(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - int cmd) -{ - int ret = 0; - - if (component->driver->trigger) - ret = component->driver->trigger(component, substream, cmd); - - return soc_component_ret(component, ret); -} - void snd_soc_component_suspend(struct snd_soc_component *component) { if (component->driver->suspend) @@ -593,3 +581,21 @@ void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream, } } } + +int snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream, + int cmd) +{ + 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->trigger) { + ret = component->driver->trigger(component, substream, cmd); + 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 2e65625b1267..a52fe33670f6 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1074,38 +1074,30 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component; - int i, ret; + int ret; ret = snd_soc_link_trigger(substream, cmd); if (ret < 0) return ret; - for_each_rtd_components(rtd, i, component) { - ret = snd_soc_component_trigger(component, substream, cmd); - if (ret < 0) - return ret; - } + ret = snd_soc_pcm_component_trigger(substream, cmd); + if (ret < 0) + return ret; return snd_soc_pcm_dai_trigger(substream, cmd); } static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component; - int i, ret; + int ret; ret = snd_soc_pcm_dai_trigger(substream, cmd); if (ret < 0) return ret; - for_each_rtd_components(rtd, i, component) { - ret = snd_soc_component_trigger(component, substream, cmd); - if (ret < 0) - return ret; - } + ret = snd_soc_pcm_component_trigger(substream, cmd); + if (ret < 0) + return ret; ret = snd_soc_link_trigger(substream, cmd); if (ret < 0) From patchwork Thu Jun 4 08:08:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 192509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80CD4C433E3 for ; Thu, 4 Jun 2020 08:12:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E76820870 for ; Thu, 4 Jun 2020 08:12:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="ExZqoczR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E76820870 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9E78E1675; Thu, 4 Jun 2020 10:12:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9E78E1675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591258371; bh=sAZNuQfyVfoxJt21Gb1lv6UFutS5OlKkDbStX17asdU=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ExZqoczRPjZdfalENXi3iMWmfeJC2rj8ymTn8qf5FeSxnEJi4+sBcNW9ycYb0aeMF v9Qy+WPI1gJCYKG1X44ue9hmbu4D4ThdBmgPM99MTNgrGMcziUtverHRE1ZUNSURtZ wL8gzYBDxROY8dIh5TAFKW8QYKIPbK+GqYblYW0c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D99F0F802EC; Thu, 4 Jun 2020 10:08:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 020C1F802F9; Thu, 4 Jun 2020 10:08:13 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 19CA6F802F7 for ; Thu, 4 Jun 2020 10:08:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 19CA6F802F7 Date: 04 Jun 2020 17:08:03 +0900 X-IronPort-AV: E=Sophos;i="5.73,471,1583161200"; d="scan'208";a="48607970" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 04 Jun 2020 17:08:03 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8AA5741D4581; Thu, 4 Jun 2020 17:08:03 +0900 (JST) Message-ID: <87h7vrw8ws.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 10/12] ASoC: soc-component: merge soc-io.c into soc-component.c User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> References: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto soc-io.c has snd_soc_component_xxx() functions for I/O. We have soc-componennt.c for it. Let's merge soc-io.c into soc-component.c By this patch, original soc-io.c functions start to use soc_component_err() when error case. Signed-off-by: Kuninori Morimoto --- sound/soc/Makefile | 2 +- sound/soc/soc-component.c | 194 ++++++++++++++++++++++++++++++++++++ sound/soc/soc-io.c | 202 -------------------------------------- 3 files changed, 195 insertions(+), 203 deletions(-) delete mode 100644 sound/soc/soc-io.c diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 7f1747518e79..ddbac3a2169f 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o soc-dai.o soc-component.o -snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o soc-link.o soc-card.o +snd-soc-core-objs += soc-pcm.o soc-devres.o soc-ops.o soc-link.o soc-card.o snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o ifneq ($(CONFIG_SND_SOC_TOPOLOGY),) diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 7624ff5b67d3..d121f5f7633c 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -2,7 +2,10 @@ // // soc-component.c // +// Copyright 2009-2011 Wolfson Microelectronics PLC. // Copyright (C) 2019 Renesas Electronics Corp. +// +// Mark Brown // Kuninori Morimoto // #include @@ -400,6 +403,197 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); #endif +/** + * snd_soc_component_read() - Read register value + * @component: Component to read from + * @reg: Register to read + * @val: Pointer to where the read value is stored + * + * Return: 0 on success, a negative error code otherwise. + */ +int snd_soc_component_read(struct snd_soc_component *component, + unsigned int reg, unsigned int *val) +{ + int ret; + + if (component->regmap) + ret = regmap_read(component->regmap, reg, val); + else if (component->driver->read) { + *val = component->driver->read(component, reg); + ret = 0; + } + else + ret = -EIO; + + return soc_component_ret(component, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_component_read); + +unsigned int snd_soc_component_read32(struct snd_soc_component *component, + unsigned int reg) +{ + unsigned int val; + int ret; + + ret = snd_soc_component_read(component, reg, &val); + if (ret < 0) + return soc_component_ret(component, -1); + + return val; +} +EXPORT_SYMBOL_GPL(snd_soc_component_read32); + +/** + * snd_soc_component_write() - Write register value + * @component: Component to write to + * @reg: Register to write + * @val: Value to write to the register + * + * Return: 0 on success, a negative error code otherwise. + */ +int snd_soc_component_write(struct snd_soc_component *component, + unsigned int reg, unsigned int val) +{ + int ret = -EIO; + + if (component->regmap) + ret = regmap_write(component->regmap, reg, val); + else if (component->driver->write) + ret = component->driver->write(component, reg, val); + + return soc_component_ret(component, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_component_write); + +static int snd_soc_component_update_bits_legacy( + struct snd_soc_component *component, unsigned int reg, + unsigned int mask, unsigned int val, bool *change) +{ + unsigned int old, new; + int ret; + + mutex_lock(&component->io_mutex); + + ret = snd_soc_component_read(component, reg, &old); + if (ret < 0) + goto out_unlock; + + new = (old & ~mask) | (val & mask); + *change = old != new; + if (*change) + ret = snd_soc_component_write(component, reg, new); +out_unlock: + mutex_unlock(&component->io_mutex); + + return soc_component_ret(component, ret); +} + +/** + * snd_soc_component_update_bits() - Perform read/modify/write cycle + * @component: Component to update + * @reg: Register to update + * @mask: Mask that specifies which bits to update + * @val: New value for the bits specified by mask + * + * Return: 1 if the operation was successful and the value of the register + * changed, 0 if the operation was successful, but the value did not change. + * Returns a negative error code otherwise. + */ +int snd_soc_component_update_bits(struct snd_soc_component *component, + unsigned int reg, unsigned int mask, unsigned int val) +{ + bool change; + int ret; + + if (component->regmap) + ret = regmap_update_bits_check(component->regmap, reg, mask, + val, &change); + else + ret = snd_soc_component_update_bits_legacy(component, reg, + mask, val, &change); + + if (ret < 0) + return soc_component_ret(component, ret); + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_component_update_bits); + +/** + * snd_soc_component_update_bits_async() - Perform asynchronous + * read/modify/write cycle + * @component: Component to update + * @reg: Register to update + * @mask: Mask that specifies which bits to update + * @val: New value for the bits specified by mask + * + * This function is similar to snd_soc_component_update_bits(), but the update + * operation is scheduled asynchronously. This means it may not be completed + * when the function returns. To make sure that all scheduled updates have been + * completed snd_soc_component_async_complete() must be called. + * + * Return: 1 if the operation was successful and the value of the register + * changed, 0 if the operation was successful, but the value did not change. + * Returns a negative error code otherwise. + */ +int snd_soc_component_update_bits_async(struct snd_soc_component *component, + unsigned int reg, unsigned int mask, unsigned int val) +{ + bool change; + int ret; + + if (component->regmap) + ret = regmap_update_bits_check_async(component->regmap, reg, + mask, val, &change); + else + ret = snd_soc_component_update_bits_legacy(component, reg, + mask, val, &change); + + if (ret < 0) + return soc_component_ret(component, ret); + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async); + +/** + * snd_soc_component_async_complete() - Ensure asynchronous I/O has completed + * @component: Component for which to wait + * + * This function blocks until all asynchronous I/O which has previously been + * scheduled using snd_soc_component_update_bits_async() has completed. + */ +void snd_soc_component_async_complete(struct snd_soc_component *component) +{ + if (component->regmap) + regmap_async_complete(component->regmap); +} +EXPORT_SYMBOL_GPL(snd_soc_component_async_complete); + +/** + * snd_soc_component_test_bits - Test register for change + * @component: component + * @reg: Register to test + * @mask: Mask that specifies which bits to test + * @value: Value to test against + * + * Tests a register with a new value and checks if the new value is + * different from the old value. + * + * Return: 1 for change, otherwise 0. + */ +int snd_soc_component_test_bits(struct snd_soc_component *component, + unsigned int reg, unsigned int mask, unsigned int value) +{ + unsigned int old, new; + int ret; + + ret = snd_soc_component_read(component, reg, &old); + if (ret < 0) + return soc_component_ret(component, ret); + new = (old & ~mask) | value; + return old != new; +} +EXPORT_SYMBOL_GPL(snd_soc_component_test_bits); + int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c deleted file mode 100644 index 1ff9175e9d5e..000000000000 --- a/sound/soc/soc-io.c +++ /dev/null @@ -1,202 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// -// soc-io.c -- ASoC register I/O helpers -// -// Copyright 2009-2011 Wolfson Microelectronics PLC. -// -// Author: Mark Brown - -#include -#include -#include -#include -#include - -/** - * snd_soc_component_read() - Read register value - * @component: Component to read from - * @reg: Register to read - * @val: Pointer to where the read value is stored - * - * Return: 0 on success, a negative error code otherwise. - */ -int snd_soc_component_read(struct snd_soc_component *component, - unsigned int reg, unsigned int *val) -{ - int ret; - - if (component->regmap) - ret = regmap_read(component->regmap, reg, val); - else if (component->driver->read) { - *val = component->driver->read(component, reg); - ret = 0; - } - else - ret = -EIO; - - return ret; -} -EXPORT_SYMBOL_GPL(snd_soc_component_read); - -unsigned int snd_soc_component_read32(struct snd_soc_component *component, - unsigned int reg) -{ - unsigned int val; - int ret; - - ret = snd_soc_component_read(component, reg, &val); - if (ret < 0) - return -1; - - return val; -} -EXPORT_SYMBOL_GPL(snd_soc_component_read32); - -/** - * snd_soc_component_write() - Write register value - * @component: Component to write to - * @reg: Register to write - * @val: Value to write to the register - * - * Return: 0 on success, a negative error code otherwise. - */ -int snd_soc_component_write(struct snd_soc_component *component, - unsigned int reg, unsigned int val) -{ - if (component->regmap) - return regmap_write(component->regmap, reg, val); - else if (component->driver->write) - return component->driver->write(component, reg, val); - else - return -EIO; -} -EXPORT_SYMBOL_GPL(snd_soc_component_write); - -static int snd_soc_component_update_bits_legacy( - struct snd_soc_component *component, unsigned int reg, - unsigned int mask, unsigned int val, bool *change) -{ - unsigned int old, new; - int ret; - - mutex_lock(&component->io_mutex); - - ret = snd_soc_component_read(component, reg, &old); - if (ret < 0) - goto out_unlock; - - new = (old & ~mask) | (val & mask); - *change = old != new; - if (*change) - ret = snd_soc_component_write(component, reg, new); -out_unlock: - mutex_unlock(&component->io_mutex); - - return ret; -} - -/** - * snd_soc_component_update_bits() - Perform read/modify/write cycle - * @component: Component to update - * @reg: Register to update - * @mask: Mask that specifies which bits to update - * @val: New value for the bits specified by mask - * - * Return: 1 if the operation was successful and the value of the register - * changed, 0 if the operation was successful, but the value did not change. - * Returns a negative error code otherwise. - */ -int snd_soc_component_update_bits(struct snd_soc_component *component, - unsigned int reg, unsigned int mask, unsigned int val) -{ - bool change; - int ret; - - if (component->regmap) - ret = regmap_update_bits_check(component->regmap, reg, mask, - val, &change); - else - ret = snd_soc_component_update_bits_legacy(component, reg, - mask, val, &change); - - if (ret < 0) - return ret; - return change; -} -EXPORT_SYMBOL_GPL(snd_soc_component_update_bits); - -/** - * snd_soc_component_update_bits_async() - Perform asynchronous - * read/modify/write cycle - * @component: Component to update - * @reg: Register to update - * @mask: Mask that specifies which bits to update - * @val: New value for the bits specified by mask - * - * This function is similar to snd_soc_component_update_bits(), but the update - * operation is scheduled asynchronously. This means it may not be completed - * when the function returns. To make sure that all scheduled updates have been - * completed snd_soc_component_async_complete() must be called. - * - * Return: 1 if the operation was successful and the value of the register - * changed, 0 if the operation was successful, but the value did not change. - * Returns a negative error code otherwise. - */ -int snd_soc_component_update_bits_async(struct snd_soc_component *component, - unsigned int reg, unsigned int mask, unsigned int val) -{ - bool change; - int ret; - - if (component->regmap) - ret = regmap_update_bits_check_async(component->regmap, reg, - mask, val, &change); - else - ret = snd_soc_component_update_bits_legacy(component, reg, - mask, val, &change); - - if (ret < 0) - return ret; - return change; -} -EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async); - -/** - * snd_soc_component_async_complete() - Ensure asynchronous I/O has completed - * @component: Component for which to wait - * - * This function blocks until all asynchronous I/O which has previously been - * scheduled using snd_soc_component_update_bits_async() has completed. - */ -void snd_soc_component_async_complete(struct snd_soc_component *component) -{ - if (component->regmap) - regmap_async_complete(component->regmap); -} -EXPORT_SYMBOL_GPL(snd_soc_component_async_complete); - -/** - * snd_soc_component_test_bits - Test register for change - * @component: component - * @reg: Register to test - * @mask: Mask that specifies which bits to test - * @value: Value to test against - * - * Tests a register with a new value and checks if the new value is - * different from the old value. - * - * Return: 1 for change, otherwise 0. - */ -int snd_soc_component_test_bits(struct snd_soc_component *component, - unsigned int reg, unsigned int mask, unsigned int value) -{ - unsigned int old, new; - int ret; - - ret = snd_soc_component_read(component, reg, &old); - if (ret < 0) - return ret; - new = (old & ~mask) | value; - return old != new; -} -EXPORT_SYMBOL_GPL(snd_soc_component_test_bits); From patchwork Thu Jun 4 08:08:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 192508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEDF2C433E4 for ; Thu, 4 Jun 2020 08:14:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C159207D5 for ; Thu, 4 Jun 2020 08:14:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="hA7S2WbX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C159207D5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BE4FB1671; Thu, 4 Jun 2020 10:13:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BE4FB1671 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591258456; bh=jfDuiLK8qb7z7WoNHo/Une5gkgXgyARLYcUNBH2PG4I=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hA7S2WbXoVZUWxEHmzJYlHAJYmLkLFqlY1A4VOooLqrTfNOUsBqJOoORs3Ywcn6LQ 6pajNnxEwG4ArLdbqwx6HdIQLkXfyQ/9HF/yftLdwXhtAdRjWbGyHpGKpeJ03srL+V SuI0vTCh8JX7DnCFRz/vLrSfUW+k4Q5O5DyuYhHY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EC595F80273; Thu, 4 Jun 2020 10:08:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F1B3F802A7; Thu, 4 Jun 2020 10:08:32 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id A047CF80299 for ; Thu, 4 Jun 2020 10:08:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A047CF80299 Date: 04 Jun 2020 17:08:24 +0900 X-IronPort-AV: E=Sophos;i="5.73,471,1583161200"; d="scan'208";a="48819449" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 04 Jun 2020 17:08:24 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AF80541D4581; Thu, 4 Jun 2020 17:08:23 +0900 (JST) Message-ID: <87eeqvw8w8.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 12/12] ASoC: soc-component: tidyup Copyright User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> References: <87v9k7w90s.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto This patch add missing company copyright Signed-off-by: Kuninori Morimoto --- include/sound/soc-component.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index aea0eb0c3fcc..4a4bb723ca9f 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -2,7 +2,8 @@ * * soc-component.h * - * Copyright (c) 2019 Kuninori Morimoto + * Copyright (C) 2019 Renesas Electronics Corp. + * Kuninori Morimoto */ #ifndef __SOC_COMPONENT_H #define __SOC_COMPONENT_H