All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component
@ 2021-10-18  2:04 Kuninori Morimoto
  2021-10-18  2:04 ` [PATCH 1/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1 Kuninori Morimoto
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2021-10-18  2:04 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

These are not a big deal, but cleanup / tidyup patch for ALSA SoC.

Kuninori Morimoto (5):
  ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1
  ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2
  ASoC: soc-component: add snd_soc_component_is_codec()
  ASoC: soc-core: tidyup empty function
  ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt()

 include/sound/soc-component.h         |  5 +++
 sound/soc/generic/simple-card-utils.c |  4 +--
 sound/soc/meson/meson-codec-glue.c    |  3 --
 sound/soc/soc-core.c                  | 51 ++++++++-------------------
 sound/soc/soc-pcm.c                   | 13 +++----
 5 files changed, 26 insertions(+), 50 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1
  2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
@ 2021-10-18  2:04 ` Kuninori Morimoto
  2021-10-18  2:05 ` [PATCH 2/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2 Kuninori Morimoto
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2021-10-18  2:04 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_pcm_hw_clean() is using "continue" during for_each_rtd_dais(),
but it is very verbose. This patch cleanup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index d22a285b9964..0e51dd6d95bd 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -898,12 +898,9 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback)
 	snd_soc_pcm_component_hw_free(substream, rollback);
 
 	/* now free hw params for the DAIs  */
-	for_each_rtd_dais(rtd, i, dai) {
-		if (!snd_soc_dai_stream_valid(dai, substream->stream))
-			continue;
-
-		snd_soc_dai_hw_free(dai, substream, rollback);
-	}
+	for_each_rtd_dais(rtd, i, dai)
+		if (snd_soc_dai_stream_valid(dai, substream->stream))
+			snd_soc_dai_hw_free(dai, substream, rollback);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2
  2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
  2021-10-18  2:04 ` [PATCH 1/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1 Kuninori Morimoto
@ 2021-10-18  2:05 ` Kuninori Morimoto
  2021-10-18  2:05 ` [PATCH 3/5] ASoC: soc-component: add snd_soc_component_is_codec() Kuninori Morimoto
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2021-10-18  2:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

DAI active count is not exchanged during for_each_rtd_dais()
loops. We don't need to keep snd_soc_dai_stream_active() as
"active" on soc_pcm_hw_clean(). This patch avoid verbose code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0e51dd6d95bd..4309e6131c40 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -879,12 +879,10 @@ static int soc_pcm_hw_clean(struct snd_pcm_substream *substream, int rollback)
 
 	/* clear the corresponding DAIs parameters when going to be inactive */
 	for_each_rtd_dais(rtd, i, dai) {
-		int active = snd_soc_dai_stream_active(dai, substream->stream);
-
 		if (snd_soc_dai_active(dai) == 1)
 			soc_pcm_set_dai_params(dai, NULL);
 
-		if (active == 1)
+		if (snd_soc_dai_stream_active(dai, substream->stream) == 1)
 			snd_soc_dai_digital_mute(dai, 1, substream->stream);
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] ASoC: soc-component: add snd_soc_component_is_codec()
  2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
  2021-10-18  2:04 ` [PATCH 1/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1 Kuninori Morimoto
  2021-10-18  2:05 ` [PATCH 2/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2 Kuninori Morimoto
@ 2021-10-18  2:05 ` Kuninori Morimoto
  2021-10-18  2:05 ` [PATCH 4/5] ASoC: soc-core: tidyup empty function Kuninori Morimoto
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2021-10-18  2:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Checking .non_legacy_dai_naming is not readable.
Let's add new snd_soc_component_is_codec().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 3a35d149e92f..a4317144ab62 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -333,6 +333,11 @@ static inline int snd_soc_component_cache_sync(
 	return regcache_sync(component->regmap);
 }
 
+static inline int snd_soc_component_is_codec(struct snd_soc_component *component)
+{
+	return component->driver->non_legacy_dai_naming;
+}
+
 void snd_soc_component_set_aux(struct snd_soc_component *component,
 			       struct snd_soc_aux_dev *aux);
 int snd_soc_component_init(struct snd_soc_component *component);
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 39ba70088127..850e968677f1 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -355,9 +355,9 @@ static int asoc_simple_init_dai_link_params(struct snd_soc_pcm_runtime *rtd,
 	struct snd_pcm_hardware hw;
 	int i, ret, stream;
 
-	/* Only codecs should have non_legacy_dai_naming set. */
+	/* Only Codecs */
 	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->non_legacy_dai_naming)
+		if (!snd_soc_component_is_codec(component))
 			return 0;
 	}
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c830e96afba2..beb3ac6e433d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1247,14 +1247,13 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 
 	/*
 	 * Flip the polarity for the "CPU" end of a CODEC<->CODEC link
-	 * the component which has non_legacy_dai_naming is Codec
 	 */
 	inv_dai_fmt = snd_soc_daifmt_clock_provider_fliped(dai_fmt);
 
 	for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
 		unsigned int fmt = dai_fmt;
 
-		if (cpu_dai->component->driver->non_legacy_dai_naming)
+		if (snd_soc_component_is_codec(cpu_dai->component))
 			fmt = inv_dai_fmt;
 
 		ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
@@ -2521,7 +2520,7 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
 
 	for (i = 0; i < count; i++) {
 		dai = snd_soc_register_dai(component, dai_drv + i, count == 1 &&
-				  !component->driver->non_legacy_dai_naming);
+					   !snd_soc_component_is_codec(component));
 		if (dai == NULL) {
 			ret = -ENOMEM;
 			goto err;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] ASoC: soc-core: tidyup empty function
  2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2021-10-18  2:05 ` [PATCH 3/5] ASoC: soc-component: add snd_soc_component_is_codec() Kuninori Morimoto
@ 2021-10-18  2:05 ` Kuninori Morimoto
  2021-10-18  2:05 ` [PATCH 5/5] ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt() Kuninori Morimoto
  2021-10-20 11:28 ` [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2021-10-18  2:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch makes empty function to 1 line.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 35 +++++++----------------------------
 1 file changed, 7 insertions(+), 28 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index beb3ac6e433d..6253cfea827c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -229,31 +229,12 @@ static void snd_soc_debugfs_exit(void)
 
 #else
 
-static inline void soc_init_component_debugfs(
-	struct snd_soc_component *component)
-{
-}
-
-static inline void soc_cleanup_component_debugfs(
-	struct snd_soc_component *component)
-{
-}
-
-static inline void soc_init_card_debugfs(struct snd_soc_card *card)
-{
-}
-
-static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card)
-{
-}
-
-static inline void snd_soc_debugfs_init(void)
-{
-}
-
-static inline void snd_soc_debugfs_exit(void)
-{
-}
+static inline void soc_init_component_debugfs(struct snd_soc_component *component) { }
+static inline void soc_cleanup_component_debugfs(struct snd_soc_component *component) { }
+static inline void soc_init_card_debugfs(struct snd_soc_card *card) { }
+static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card) { }
+static inline void snd_soc_debugfs_init(void) { }
+static inline void snd_soc_debugfs_exit(void) { }
 
 #endif
 
@@ -739,9 +720,7 @@ static void soc_resume_init(struct snd_soc_card *card)
 #else
 #define snd_soc_suspend NULL
 #define snd_soc_resume NULL
-static inline void soc_resume_init(struct snd_soc_card *card)
-{
-}
+static inline void soc_resume_init(struct snd_soc_card *card) { }
 #endif
 
 static struct device_node
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt()
  2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2021-10-18  2:05 ` [PATCH 4/5] ASoC: soc-core: tidyup empty function Kuninori Morimoto
@ 2021-10-18  2:05 ` Kuninori Morimoto
  2021-10-20 11:28 ` [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2021-10-18  2:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Do nothing if format was zero at snd_soc_runtime_set_dai_fmt().
soc-core.c can be more simple code by this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/meson/meson-codec-glue.c |  3 ---
 sound/soc/soc-core.c               | 11 ++++++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/sound/soc/meson/meson-codec-glue.c b/sound/soc/meson/meson-codec-glue.c
index d07270d17cee..2870cfad813a 100644
--- a/sound/soc/meson/meson-codec-glue.c
+++ b/sound/soc/meson/meson-codec-glue.c
@@ -113,9 +113,6 @@ int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
 	/* Replace link params with the input params */
 	rtd->dai_link->params = &in_data->params;
 
-	if (!in_data->fmt)
-		return 0;
-
 	return snd_soc_runtime_set_dai_fmt(rtd, in_data->fmt);
 }
 EXPORT_SYMBOL_GPL(meson_codec_glue_output_startup);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6253cfea827c..bdbaf14dc9fc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1218,6 +1218,9 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	unsigned int i;
 	int ret;
 
+	if (!dai_fmt)
+		return 0;
+
 	for_each_rtd_codec_dais(rtd, i, codec_dai) {
 		ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
 		if (ret != 0 && ret != -ENOTSUPP)
@@ -1261,11 +1264,9 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 		return ret;
 
 	snd_soc_runtime_get_dai_fmt(rtd);
-	if (dai_link->dai_fmt) {
-		ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
-		if (ret)
-			return ret;
-	}
+	ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
+	if (ret)
+		return ret;
 
 	/* add DPCM sysfs entries */
 	soc_dpcm_debugfs_add(rtd);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component
  2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2021-10-18  2:05 ` [PATCH 5/5] ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt() Kuninori Morimoto
@ 2021-10-20 11:28 ` Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2021-10-20 11:28 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

On 18 Oct 2021 11:04:19 +0900, Kuninori Morimoto wrote:
> These are not a big deal, but cleanup / tidyup patch for ALSA SoC.
> 
> Kuninori Morimoto (5):
>   ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1
>   ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2
>   ASoC: soc-component: add snd_soc_component_is_codec()
>   ASoC: soc-core: tidyup empty function
>   ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt()
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1
      commit: 121966d03b320efe77852aaf68aa8af3fb4a72cd
[2/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2
      commit: 86e4aef6c9a113374f69c6dc63877e10935926a7
[3/5] ASoC: soc-component: add snd_soc_component_is_codec()
      commit: 01e90ee15e81f57d309d0ce1f0e16869e011b800
[4/5] ASoC: soc-core: tidyup empty function
      commit: 41b1774fb814544d2224bdfd893c060fdfed995b
[5/5] ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt()
      commit: 7db07e37e13cfd46039d82aed91092185eac6565

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-20 11:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18  2:04 [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Kuninori Morimoto
2021-10-18  2:04 ` [PATCH 1/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step1 Kuninori Morimoto
2021-10-18  2:05 ` [PATCH 2/5] ASoC: soc-pcm: tidyup soc_pcm_hw_clean() - step2 Kuninori Morimoto
2021-10-18  2:05 ` [PATCH 3/5] ASoC: soc-component: add snd_soc_component_is_codec() Kuninori Morimoto
2021-10-18  2:05 ` [PATCH 4/5] ASoC: soc-core: tidyup empty function Kuninori Morimoto
2021-10-18  2:05 ` [PATCH 5/5] ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt() Kuninori Morimoto
2021-10-20 11:28 ` [PATCH 0/5] ASoC: cleanup / tidyup soc-pcm/core/component Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.