public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name()
@ 2026-05-28  0:48 Kuninori Morimoto
  2026-05-28  7:19 ` Péter Ujfalusi
  2026-05-28 11:20 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2026-05-28  0:48 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Bard Liao, Chen-Yu Tsai,
	Daniel Baluta, Jaroslav Kysela, Kai Vehmanen, Liam Girdwood,
	Mark Brown, Matthias Brugger, Peter Ujfalusi,
	Pierre-Louis Bossart, Takashi Iwai, linux-arm-kernel, linux-sound

Some drivers want to use topology name, but currently each drivers are
setting it by own method.
This patch adds new snd_soc_card_set_topology_name() and do it by
same method.

Almost all driver doesn't set topology name, let's remove fixed name
array, and use devm_kasprintf() instead.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas•com>
---
v1 -> v2
	- snd_soc_card_set_topology_name() checks prefix, too

 include/sound/soc-card.h                        |  2 ++
 include/sound/soc.h                             |  3 +--
 .../soc/mediatek/common/mtk-soundcard-driver.c  |  7 ++-----
 sound/soc/soc-card.c                            | 13 +++++++++++++
 sound/soc/soc-core.c                            | 17 +----------------
 sound/soc/sof/nocodec.c                         |  4 ++--
 6 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
index ecc02e955279f..1f1e7d45f5533 100644
--- a/include/sound/soc-card.h
+++ b/include/sound/soc-card.h
@@ -47,6 +47,8 @@ int snd_soc_card_late_probe(struct snd_soc_card *card);
 void snd_soc_card_fixup_controls(struct snd_soc_card *card);
 int snd_soc_card_remove(struct snd_soc_card *card);
 
+void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *preifx);
+
 int snd_soc_card_set_bias_level(struct snd_soc_card *card,
 				struct snd_soc_dapm_context *dapm,
 				enum snd_soc_bias_level level);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 8681dd3f4252f..10ad80f930c2e 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -987,7 +987,7 @@ struct snd_soc_card {
 	bool pci_subsystem_set;
 #endif /* CONFIG_PCI */
 
-	char topology_shortname[32];
+	char *topology_shortname;
 
 	struct device *dev;
 	struct snd_card *snd_card;
@@ -1084,7 +1084,6 @@ struct snd_soc_card {
 #endif
 	/* bit field */
 	unsigned int instantiated:1;
-	unsigned int topology_shortname_created:1;
 	unsigned int fully_routed:1;
 	unsigned int probed:1;
 	unsigned int component_chaining:1;
diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c
index a2a30a87a359f..cdff7322426a9 100644
--- a/sound/soc/mediatek/common/mtk-soundcard-driver.c
+++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c
@@ -289,11 +289,8 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)
 		soc_card_data->sof_priv = pdata->sof_priv;
 		card->probe = mtk_sof_card_probe;
 		card->late_probe = mtk_sof_card_late_probe;
-		if (!card->topology_shortname_created) {
-			snprintf(card->topology_shortname, 32, "sof-%s", card->name);
-			card->topology_shortname_created = true;
-		}
-		card->name = card->topology_shortname;
+
+		snd_soc_card_set_topology_name(card, "sof");
 	}
 
 	/*
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 235427d690617..282d666dae9ec 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -246,3 +246,16 @@ void snd_soc_card_remove_dai_link(struct snd_soc_card *card,
 		card->remove_dai_link(card, dai_link);
 }
 EXPORT_SYMBOL_GPL(snd_soc_card_remove_dai_link);
+
+void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *prefix)
+{
+	if (!prefix || !card->name)
+		return;
+
+	if (!card->topology_shortname)
+		card->topology_shortname = devm_kasprintf(card->dev, GFP_KERNEL,
+							  "%s-%s", prefix, card->name);
+
+	card->name = card->topology_shortname;
+}
+EXPORT_SYMBOL_GPL(snd_soc_card_set_topology_name);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 55130eea04544..e96dd4a3f46c7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1990,7 +1990,6 @@ static inline int snd_soc_set_dmi_name(struct snd_soc_card *card)
 static void soc_check_tplg_fes(struct snd_soc_card *card)
 {
 	struct snd_soc_component *component;
-	const struct snd_soc_component_driver *comp_drv;
 	struct snd_soc_dai_link *dai_link;
 	int i;
 
@@ -2051,21 +2050,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
 		}
 
 		/* Inform userspace we are using alternate topology */
-		if (component->driver->topology_name_prefix) {
-
-			/* topology shortname created? */
-			if (!card->topology_shortname_created) {
-				comp_drv = component->driver;
-
-				snprintf(card->topology_shortname, 32, "%s-%s",
-					 comp_drv->topology_name_prefix,
-					 card->name);
-				card->topology_shortname_created = true;
-			}
-
-			/* use topology shortname */
-			card->name = card->topology_shortname;
-		}
+		snd_soc_card_set_topology_name(card, component->driver->topology_name_prefix);
 	}
 }
 
diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c
index c0c906a78ebae..11a95dba3c9cf 100644
--- a/sound/soc/sof/nocodec.c
+++ b/sound/soc/sof/nocodec.c
@@ -15,7 +15,6 @@
 
 static struct snd_soc_card sof_nocodec_card = {
 	.name = "nocodec", /* the sof- prefix is added by the core */
-	.topology_shortname = "sof-nocodec",
 	.owner = THIS_MODULE
 };
 
@@ -89,9 +88,10 @@ static int sof_nocodec_probe(struct platform_device *pdev)
 	int ret;
 
 	card->dev = &pdev->dev;
-	card->topology_shortname_created = true;
 	mach = pdev->dev.platform_data;
 
+	snd_soc_card_set_topology_name(card, "sof");
+
 	ret = sof_nocodec_setup(card->dev, mach->mach_params.num_dai_drivers,
 				mach->mach_params.dai_drivers);
 	if (ret < 0)
-- 
2.43.0



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

* Re: [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name()
  2026-05-28  0:48 [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name() Kuninori Morimoto
@ 2026-05-28  7:19 ` Péter Ujfalusi
  2026-05-28 11:20 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Péter Ujfalusi @ 2026-05-28  7:19 UTC (permalink / raw)
  To: Kuninori Morimoto, AngeloGioacchino Del Regno, Bard Liao,
	Chen-Yu Tsai, Daniel Baluta, Jaroslav Kysela, Kai Vehmanen,
	Liam Girdwood, Mark Brown, Matthias Brugger, Pierre-Louis Bossart,
	Takashi Iwai, linux-arm-kernel, linux-sound



On 28/05/2026 03:48, Kuninori Morimoto wrote:
> Some drivers want to use topology name, but currently each drivers are
> setting it by own method.
> This patch adds new snd_soc_card_set_topology_name() and do it by
> same method.
> 
> Almost all driver doesn't set topology name, let's remove fixed name
> array, and use devm_kasprintf() instead.

Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux•intel.com>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas•com>
> ---
> v1 -> v2
> 	- snd_soc_card_set_topology_name() checks prefix, too
> 
>  include/sound/soc-card.h                        |  2 ++
>  include/sound/soc.h                             |  3 +--
>  .../soc/mediatek/common/mtk-soundcard-driver.c  |  7 ++-----
>  sound/soc/soc-card.c                            | 13 +++++++++++++
>  sound/soc/soc-core.c                            | 17 +----------------
>  sound/soc/sof/nocodec.c                         |  4 ++--
>  6 files changed, 21 insertions(+), 25 deletions(-)
> 
> diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
> index ecc02e955279f..1f1e7d45f5533 100644
> --- a/include/sound/soc-card.h
> +++ b/include/sound/soc-card.h
> @@ -47,6 +47,8 @@ int snd_soc_card_late_probe(struct snd_soc_card *card);
>  void snd_soc_card_fixup_controls(struct snd_soc_card *card);
>  int snd_soc_card_remove(struct snd_soc_card *card);
>  
> +void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *preifx);
> +
>  int snd_soc_card_set_bias_level(struct snd_soc_card *card,
>  				struct snd_soc_dapm_context *dapm,
>  				enum snd_soc_bias_level level);
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 8681dd3f4252f..10ad80f930c2e 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -987,7 +987,7 @@ struct snd_soc_card {
>  	bool pci_subsystem_set;
>  #endif /* CONFIG_PCI */
>  
> -	char topology_shortname[32];
> +	char *topology_shortname;
>  
>  	struct device *dev;
>  	struct snd_card *snd_card;
> @@ -1084,7 +1084,6 @@ struct snd_soc_card {
>  #endif
>  	/* bit field */
>  	unsigned int instantiated:1;
> -	unsigned int topology_shortname_created:1;
>  	unsigned int fully_routed:1;
>  	unsigned int probed:1;
>  	unsigned int component_chaining:1;
> diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c
> index a2a30a87a359f..cdff7322426a9 100644
> --- a/sound/soc/mediatek/common/mtk-soundcard-driver.c
> +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c
> @@ -289,11 +289,8 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)
>  		soc_card_data->sof_priv = pdata->sof_priv;
>  		card->probe = mtk_sof_card_probe;
>  		card->late_probe = mtk_sof_card_late_probe;
> -		if (!card->topology_shortname_created) {
> -			snprintf(card->topology_shortname, 32, "sof-%s", card->name);
> -			card->topology_shortname_created = true;
> -		}
> -		card->name = card->topology_shortname;
> +
> +		snd_soc_card_set_topology_name(card, "sof");
>  	}
>  
>  	/*
> diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
> index 235427d690617..282d666dae9ec 100644
> --- a/sound/soc/soc-card.c
> +++ b/sound/soc/soc-card.c
> @@ -246,3 +246,16 @@ void snd_soc_card_remove_dai_link(struct snd_soc_card *card,
>  		card->remove_dai_link(card, dai_link);
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_card_remove_dai_link);
> +
> +void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *prefix)
> +{
> +	if (!prefix || !card->name)
> +		return;
> +
> +	if (!card->topology_shortname)
> +		card->topology_shortname = devm_kasprintf(card->dev, GFP_KERNEL,
> +							  "%s-%s", prefix, card->name);
> +
> +	card->name = card->topology_shortname;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_card_set_topology_name);
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 55130eea04544..e96dd4a3f46c7 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1990,7 +1990,6 @@ static inline int snd_soc_set_dmi_name(struct snd_soc_card *card)
>  static void soc_check_tplg_fes(struct snd_soc_card *card)
>  {
>  	struct snd_soc_component *component;
> -	const struct snd_soc_component_driver *comp_drv;
>  	struct snd_soc_dai_link *dai_link;
>  	int i;
>  
> @@ -2051,21 +2050,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
>  		}
>  
>  		/* Inform userspace we are using alternate topology */
> -		if (component->driver->topology_name_prefix) {
> -
> -			/* topology shortname created? */
> -			if (!card->topology_shortname_created) {
> -				comp_drv = component->driver;
> -
> -				snprintf(card->topology_shortname, 32, "%s-%s",
> -					 comp_drv->topology_name_prefix,
> -					 card->name);
> -				card->topology_shortname_created = true;
> -			}
> -
> -			/* use topology shortname */
> -			card->name = card->topology_shortname;
> -		}
> +		snd_soc_card_set_topology_name(card, component->driver->topology_name_prefix);
>  	}
>  }
>  
> diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c
> index c0c906a78ebae..11a95dba3c9cf 100644
> --- a/sound/soc/sof/nocodec.c
> +++ b/sound/soc/sof/nocodec.c
> @@ -15,7 +15,6 @@
>  
>  static struct snd_soc_card sof_nocodec_card = {
>  	.name = "nocodec", /* the sof- prefix is added by the core */
> -	.topology_shortname = "sof-nocodec",
>  	.owner = THIS_MODULE
>  };
>  
> @@ -89,9 +88,10 @@ static int sof_nocodec_probe(struct platform_device *pdev)
>  	int ret;
>  
>  	card->dev = &pdev->dev;
> -	card->topology_shortname_created = true;
>  	mach = pdev->dev.platform_data;
>  
> +	snd_soc_card_set_topology_name(card, "sof");
> +
>  	ret = sof_nocodec_setup(card->dev, mach->mach_params.num_dai_drivers,
>  				mach->mach_params.dai_drivers);
>  	if (ret < 0)

-- 
Péter



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

* Re: [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name()
  2026-05-28  0:48 [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name() Kuninori Morimoto
  2026-05-28  7:19 ` Péter Ujfalusi
@ 2026-05-28 11:20 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-05-28 11:20 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Bard Liao, Chen-Yu Tsai,
	Daniel Baluta, Jaroslav Kysela, Kai Vehmanen, Liam Girdwood,
	Matthias Brugger, Peter Ujfalusi, Pierre-Louis Bossart,
	Takashi Iwai, linux-arm-kernel, linux-sound, Kuninori Morimoto

On Thu, 28 May 2026 00:48:01 +0000, Kuninori Morimoto wrote:
> ASoC: soc-card: add snd_soc_card_set_topology_name()

Applied to

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

Thanks!

[1/1] ASoC: soc-card: add snd_soc_card_set_topology_name()
      https://git.kernel.org/broonie/sound/c/ec4489c43efe

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] 3+ messages in thread

end of thread, other threads:[~2026-05-29 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28  0:48 [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name() Kuninori Morimoto
2026-05-28  7:19 ` Péter Ujfalusi
2026-05-28 11:20 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox